Skip to content

Instantly share code, notes, and snippets.

@ambethia
Created March 9, 2010 04:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ambethia/326172 to your computer and use it in GitHub Desktop.
Save ambethia/326172 to your computer and use it in GitHub Desktop.
HTML5 Upload Progress
var xhr = new XMLHttpRequest();
xhr.upload['onprogress'] = function(xhrpe) {
console.log(xhrpe);
};
var file = document.getElementById('source').files[0];
xhr.open("POST", this.action, true);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", file.fileName);
xhr.setRequestHeader("X-File-Size", file.fileSize);
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.send(file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment