0

I am using the following javascript to upload files to a .Net WCF service.

When using Chrome the onprogress function is called regularly.

When using Edge it only gets called once at the end.

var xhr = new XMLHttpRequest(); xhr.open('POST', '/upload?filename=' + encodeURIComponent(fileToUpload.serverFilename), true); // Listen to the upload progress. xhr.upload.onprogress = function (e) { if (e.lengthComputable) { progress.setValue(e.loaded / e.total); } }; xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { if (onSuccess !== undefined) onSuccess(fileToUpload); } else { Ext.Msg.alert('Upload Error', 'File: ' + fileToUpload.filename + '<br><br>Error: ' + xhr.status + ' ' + xhr.statusText); if (onError !== undefined) onError(); } } }; xhr.ontimeout = function () { console.log('transfer timed out') } var reader = new FileReader(); reader.onload = function () { var arrayBuffer = this.result; xhr.send(arrayBuffer); } reader.readAsArrayBuffer(fileToUpload.file); 

This behaviour is obviously inconsistent but I would suggest the Edge is not behaving as it should be (there is no point in an onprogress event if it only gets called at the end).

Any workaround? Or have I misunderstood how this is supposed to work (Chrome seems to understand just fine though)?

Or is it a Microsoft bug or non-compliance? And need to wait 10 years to see if they bother to fix it.

5
  • So what is your question? Commented Sep 20, 2018 at 16:29
  • Sorry, I imagined that would be obvious, I'll update accordingly. Have you got anything useful to add or just here to critique the question? Commented Sep 20, 2018 at 16:38
  • You didn't ask a question. So therefore I can't possibly critique it. I actually came to this post in the hope that I could answer a question for you and help, but you didn't ask a question. In the time it took you to post your snarky comment reply you could have instead ... wait for it ... edited your post and asked a question. Commented Sep 20, 2018 at 16:42
  • I agree, it's a duplicate. Couldn't find that earlier despite searching. Thanks. Just another frustrating day with poor Microsoft products :o( Commented Sep 20, 2018 at 18:15
  • @Community are you sure the bug still exists two major versions later? (It seems not has been fixed yet, though). Commented Sep 21, 2018 at 11:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.