Last active
March 18, 2016 12:37
-
-
Save ansariabr/b86df24ccfb96415aa95 to your computer and use it in GitHub Desktop.
Upload photo and/or sign 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 formData = new FormData(); | |
formData.append("Photo", $("#filePhotoUpload").get(0).files[0]);//filePhotoUpload is html file element | |
formData.append("Sign", $("#fileSignUpload").get(0).files[0]);//fileSignUpload is html file element | |
formData.append("Token", "<<append the JWT in this parameter>>"); | |
formData.append("PhotoUploaded", "Y"); //N if not uploading a photo | |
formData.append("SignUploaded", "Y"); //N if not uploading a sign | |
var ajaxRequest = $.ajax({ | |
type: "POST", | |
url: 'fileserver.com/FileUploader/api/filenx/UploadPhotoSign', | |
data: formData, | |
contentType: "application/json; charset=utf-8", | |
contentType: false, | |
processData: false | |
}); | |
ajaxRequest.done(function (data) { | |
var response = $.parseJSON(data); | |
if (response.Result == 1) { | |
var uploadedPhotoURL = response.PhotoURL; | |
var uploadedPhotoFileName = response.PhotoFileName; | |
var uploadedSignURL = response.SignURL; | |
var uploadedSignFileName = response.SignFileName; | |
} | |
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