RadhaKrishnaKiJaya
asked on
Pass the drag drop file to controller MVC
Hi Experts,
I am trying to drag and drop an file and then upload it on click of a button. I save the file in a hidden variable, So I can pass it when I submit the form.
jQuery('#dropZone').on('drop dragdrop', function (e) {
e.preventDefault();
fileName = e.originalEvent.dataTransfer.files[0].name;
file = e.originalEvent.dataTransfer.files[0];
jQuery('#dragDropLogoUpload').val(file);
jQuery(this).html(fileName);
});
#dragDropLogoUpload is the hidden variable
jQuery('#logoSubmit').click(function () {
jQuery('#dragDropLogoUpload').val();
jQuery('#frmSubmitLogoPost').submit();
}
When I Submit it goes to the controller -
public ActionResult SubmitLogo(HttpPostedFileBase dragDropLogoUpload) {
}
But for some reason the value of "dragDropLogoUpload" is coming as null.
Please suggest what am I doing wrong?
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you tried this
Open in new window
Check the article here
https://www.aspsnippets.com/Articles/Implement-Drag-and-Drop-File-upload-in-ASPNet-MVC.aspx