Created
June 25, 2014 19:26
-
-
Save LulzAugusto/8e1391202873aeb560cc to your computer and use it in GitHub Desktop.
How to setup a jQuery Ajax request to upload file(s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileField = document.getElementById("file_picker"); | |
var file = fileField.files[0]; // Use multiple attr in your input field to upload more than one file | |
var formData = new FormData(); | |
formData.append('filecsv', file, file.name); | |
$.ajax({ | |
type: "POST", | |
url: "", | |
processData: false, | |
contentType: false, | |
dataType: 'text', | |
data: formData, | |
}) | |
.done(function(data) { | |
// do stuff | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment