Skip to content

Instantly share code, notes, and snippets.

@wayanjimmy
Created November 14, 2014 05:05
Show Gist options
  • Save wayanjimmy/d07d13927739c3482e76 to your computer and use it in GitHub Desktop.
Save wayanjimmy/d07d13927739c3482e76 to your computer and use it in GitHub Desktop.
jquery ajax fileupload
$('#file').change(function(){
var formData = new FormData();
var current = $(this);
formData.append("file", $(this)[0].files[0]);
// additional data
formData.append("id", "1");
var promise = $.ajax({
url: "url",
type: 'post',
data: formData,
processData: false,
contentType: false
});
promise.done(function(result){
// event when upload done
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment