Is there an alternative for File() constructor for Safari and IE?

后端 未结 4 1761
刺人心
刺人心 2020-12-30 04:05

I am using the File() constructor for creating file object for uploading a blob file to the server. The following code works fine for Chrome, but fails for Safari and Intern

4条回答
  •  醉话见心
    2020-12-30 04:19

    According to web "Can I use" Safari does not support the new File() constructor. See this link http://caniuse.com/#feat=fileapi

    So I think you have to either use FileReader or maybe use some of the polyfills listed here https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills

    Especially this one could be useful for you https://github.com/mailru/FileAPI (I did not use it myself)

    Also have a look at this SO answer What to use instead of FileReader for Safari?

提交回复
热议问题