Last active
August 29, 2015 14:04
-
-
Save imposibrus/ba4e2ce0e689add73f66 to your computer and use it in GitHub Desktop.
Upload file with $.ajax()
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 fd = new FormData(); | |
fd.append('file', $('input[type="file"]')[0].files[0]); | |
$.ajax({ | |
url: '/photoUpload', | |
data: fd, | |
processData: false, | |
contentType: false, | |
cache: false, | |
type: 'POST', | |
success: function(data){ | |
console.log(data); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment