1

The File() constructor is not supported in IE and Safari.CanIUse

Is there a nice solution to this in Angular/JavaScript?

var file = new File(byteArrays, tempfilename, { type: contentType });

Could I create the file in other ways, that is supported by IE an Safari?

Delete me
  • 587
  • 2
  • 8
  • 21
  • Please clarify what exactly isn't supported or what solution you'd want to an unsupported feature. – deceze Jun 09 '15 at 08:47
  • 2
    http://caniuse.com/#feat=fileapi The File() constructor isent supported. The code above i falling because of that.. – Delete me Jun 09 '15 at 08:59

1 Answers1

1

If you absolutely want or need to use the File API, there's mOxie polyfill suggested by CanIUse.

Ivan Krechetov
  • 18,802
  • 8
  • 49
  • 60
  • 1
    What alternatives do I have? Without rewritting the complete program.. – Delete me Jun 09 '15 at 09:04
  • 1
    Hard to say without knowing the details of the problem you're solving – Ivan Krechetov Jun 09 '15 at 09:10
  • I "just" need to create a base64 file whit that type and filename. I creathe the file in a Base64ToFile converter. Called like this: base64ToFile(tempcroppedImage, 'tempfilename.jpg', 'image/jpeg'); – Delete me Jun 09 '15 at 09:15
  • 1
    Is there a good alternative to create a file with javascript? – Delete me Jun 09 '15 at 09:44
  • Are you sure you really need a file? May be you can solve your actual higher-level problem with and data: URL? http://stackoverflow.com/a/8126887/6430 As for the File, the polyfill is a good option. Something like that need to rely on a native browser extension like Flash, Java Applet, ActiveX and alike – Ivan Krechetov Jun 11 '15 at 07:54
  • 1
    I solved the problem today by creating a blob instead. FileReader is supported by all browsers. – Delete me Jun 12 '15 at 10:00
  • @Deleteme: thanks! Blob to the rescue. – Roy Tinker Jun 01 '17 at 03:47
  • The mOxie polyfill is not available for commercial use without purchasing a licence. – markdon Sep 18 '20 at 04:43