javascript - XmlHttpRequest file upload strange behavior in IE11 -
i have servlet handle file upload via http post.
also, have client-side page upload files.
this strange thing in ie11:
i uploaded file (abc.tiff). upload successful.
i uploaded file (bcd.tiff). upload successful.
i uploaded abc.tiff again. upload successful.
now strange, upload abc.tiff again. ie did not make http post upload. knew monitoring network in developer mode.
i repeated above steps many times , got same outcomes. in general, in ie11, if make consecutive uploads of same file, http post not invoked on client side.
i not have issue in firefox. in firefox, consecutive uploads of same file succeed.
could let me know why behaves in ie11? there way fix issue? thanks.
this client-side code:
<!doctype html> <html> <body> <input type="file" id="upload" size="50" onchange="process()"> <p id="message"></p> <script> function process() { var input = document.getelementbyid("upload"); var file = input.files[0]; document.getelementbyid("message").innerhtml = file.name + ' ' + file.size; var reader = new filereader(); reader.filename = file.name; reader.onload = imageisloaded; reader.readasdataurl(file); } function imageisloaded(e) { var bytearray = atob(e.target.result.split(",")[1]); var temp = new uint8array(new arraybuffer(bytearray.length)); for(var = 0; < bytearray.length; i++) { temp[i] = bytearray.charcodeat(i); } var blob = new blob([temp], {type: 'image/tiff'}); sendfile(blob, e.target.filename); } function sendfile(blob, filename) { var formdata = new formdata(); formdata.append('file', blob, filename); var xhr = new xmlhttprequest(); var millisec = new date().gettime(); xhr.open('post', 'http://localhost:8080/webapplication9/datatransfer?dummy=' + millisec, true); xhr.send(formdata); } </script> </body> </html>
Comments
Post a Comment