Skip to content

Instantly share code, notes, and snippets.

@lgersman
Created September 17, 2012 14:31
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 lgersman/3737712 to your computer and use it in GitHub Desktop.
Save lgersman/3737712 to your computer and use it in GitHub Desktop.
jquery.upload.js usage example using global progress event handler
/*
* track file upload progress using global progress event handler.
*
* See https://github.com/lgersman/jquery.orangevolt-ampere/blob/master/public/lib/ampere/jquery.upload.js
*/
$( document).on( 'ajaxProgress', function( jqEvent, progressEvent, upload, jqXHR) {
if( progressEvent.lengthComputable) {
var percent = Math.round( progressEvent.loaded * 100 / progressEvent.total) + '%';
if( upload) {
console.log( percent + ' uploaded');
} else {
console.log( percent + ' downloaded');
}
}
});
$.upload( form.action, new FormData( myForm))
.done( function() {
console.log( 'Finished upload');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment