Last active
March 18, 2016 11:37
-
-
Save ansariabr/f746c6a5f7961c4c0e53 to your computer and use it in GitHub Desktop.
Uploading File To FileUploader using jQuery
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 data = new FormData(); | |
data.append("UploadedImage", $("#fileUpload").get(0).files[0]); | |
data.append("Token", "<<append the JWT in this parameter>>"); | |
var ajaxRequest = $.ajax({ | |
type: "POST", | |
url: 'fileserver.com/FileUploader/api/filenx/Upload', | |
contentType: false, | |
processData: false, | |
data: data | |
}); | |
ajaxRequest.done(function (data) { | |
var response = $.parseJSON(data); | |
if (response.Result == 1) { | |
var uploadeFileName = response.FileName; | |
var uploadedFileURL = response.FileURL; | |
} | |
else { | |
alert('Error Occured:' + response.Message); | |
} | |
}); | |
ajaxRequest.error(function (xhr, status) { | |
console.log(xhr); | |
console.log(status); | |
alert('Upload failed, try again later'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment