Hi,
I'm trying out the new XMLHTTPRequestUpload feature to upload some files to a php script, it mostly works fine, the upload starts, I get the finish response etc - but the progress doesn't seem to work.
Looking that the event.loaded value - In firefox I seem to get a random value between 0 and the file size; in Chrome (where I'm mostly working) I get the total file size, even though the readystate hasn't reached '4' and the Developer Tools window still shows the file to be loading?
Any ideas?
Heres my code:
var xhr = new XMLHttpRequest()
xhr.upload.addEventListener('progress', function(event) {
if (event.lengthComputable) {
$('ajaxFeedbackDiv').innerHTML = event.loaded + ' / ' + event.total;
}
}, false);
xhr.onreadystatechange = function(event) {
if (event.target.readyState == 4) {
updateFileList();
}
};
xhr.open("POST", "_code/upload.php");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Size", file.size);
xhr.setRequestHeader("X-File-Type", file.type);
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr(file);
Many thanks
Ben