Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2013 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5208652 to your computer and use it in GitHub Desktop.
Save anonymous/5208652 to your computer and use it in GitHub Desktop.
xhr.upload.addEventListener("progress", function (e) {
if (e && e.lengthComputable) {
p = (e.loaded / e.total);
var percent = Math.ceil(p * 1000) / 10;
$("#uploadprogress").val(e.loaded);
$("#uploadprogress").attr("max", e.total);
$("#progress").text("Uploading... " + percent + "%");
}
});
xhr.upload.addEventListener("load", function(e) {
$("#uploadprogress").attr("value", false);
$("#uploadprogress").attr("max", false);
$("#progress").text("Checking file...");
});
xhr.addEventListener("readystatechange", function(e) {
if (this.readyState === 4) {
$("#progress").text("File is done being checked...");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment