I'm using XMLHttpRequest (with jQuery) to get the upload progress of multiple files. By adding a "progress" event listener to the XMLHttpRequest object I can get event.loaded
and event.total
. Those variables give me the loaded and total bytes of all the files combined.
What I'd like to do is get the progress of each individual file, but from what I can see that information isn't available with XMLHttpRequest. Is that true?
I don't think this is even necessary, but here's my code:
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function(event) {
var percent = 0;
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
updateProgressBar(percent);
}, false);
}
return xhr;
If I can accomplish this with XMLHttpRequest that would be great. Any info on this would be appreciated.