Sending files /file upload using ajax which works in IE9

后端 未结 1 468
清歌不尽
清歌不尽 2020-12-15 09:15

I need to upload files using ajax which has to be supported in IE9. I was using FormData as mentioned here. My code looks like this:

var files = new FormData         


        
相关标签:
1条回答
  • 2020-12-15 09:41

    Unfortunately you cannot use Ajax (XMLHttpRequest in other words) for sending files, but you can implement a similar behavior using the <iframe/> with a <form method="post" enctype="multipart/form-data"/> that contains an <input type="file"/> which sends a user chosen file using the "natural" way. You can use javascript to call the form.submit() then poll that <iframe/> from parent document to check whether the file upload process is done.

    jQuery has a lot of cool plugins for getting this job done, there is my favorite one, for example.

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