FormData in IE 11 not defined

后端 未结 2 1397
天涯浪人
天涯浪人 2021-01-06 07:45

I have the following script to get the file data from a input type of file:

var uploadfiles = $(\"#upFile\").get(0);
var uploadedfiles = uploadfiles.files;

         


        
相关标签:
2条回答
  • 2021-01-06 08:09

    After checking docmode in IE developer tools it turned out it was reverted to 9 for some reason, had an older meta tag for X-UA-Compatible on my master page which I changed to:

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    

    And FormData had no problems at all.

    0 讨论(0)
  • 2021-01-06 08:17

    FormData is not fully supported on IE11.

    To be specific: FormData instance does not have method 'set'. You need to use append method instead, as follows:

    const formData = new FormData();
    formData.append('your_key_name', 'your_value_goes_here');
    

    Setting meta http-equiv to IE=edge will not make 'set' property work and is not needed.

    Reference: https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

    0 讨论(0)
提交回复
热议问题