As you may know, the File constructor support in Internet Explorer doesn’t exist. For security reasons, you may not be able to abstract the File object as you would like to do normally. It doesn’t if other Libraries that use the File API to upload files like the ng2-file-upload require it, it won’t work.

According to MDN Docs, the File interface provides information about files and allows JavaScript in a web page to access their content. A File object is a specific kind of a Blob, and can be used in any context that a Blob can. In particular, FileReaderURL.createObjectURL()createImageBitmap(), and XMLHttpRequest.send() accept both Blobs and Files.

Since we needed to create Text Files from a TextArea input in a browser and IE didn’t allowed me to do that, after finding the solution for that I’ve decided to share with you what I’ve done to solve the problem in our project while using vanilla JavaScript.

Image result for file
A bunch of files (Findel International)

How to hack support in IE

The script below teaches on how to create a FileUploader object that manages a upload queue and creates new object files on the fly. The magic for Internet Explorer happens at line 43 and extends until the end.

The solution to File Constructor support

Basically the solution relies on creating a Blob object in Internet Explorer and setting some specific properties with the File Name, Last Modified Date and Type. In Type Script you can also specify an explicit cast for the right type of object you want, the File Object.

Hope it can help you finding a solution for your problem and getting more time to spend on drinking a cup of coffee with your colleagues and not dealing with File constructor support in Internet Explorer.

References:
Stack Overflow – Convert blob to file