Skip to content

Instantly share code, notes, and snippets.

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