I need to upload file using jquery from my modal popup.
But I get the HttpPostedFileBase
as null during ajax call.
Can anyone help me out on this. Below is the jquery code:
function uploadDocument(contactId, tripId, file) {
if ($('#documentUploadInput').val() == '') {
alertify.error('Please select a file to upload');
return;
}
$.ajax({
url: '/CRMDomain/ContactDetail/UploadDocument',
data: { contactId: contactId, tripId: tripId, file: file },
type: 'POST',
success: function () {
alertify.success('Uploaded');
$('#CRMUploadDocumentModal').modal('hide');
},
error: function () {
alertify.error('Not Uploaded');
}
});
}
And this is the way i call the jquery function:
<input id="btnSave"
type="button"
value="Upload"
class="btn btn-default" onclick='uploadDocument($("#ContactId").val(), $("#tripId").val(), $("#documentUploadInput")[0].files[0]);' />