I need to upload a file along with several other input data with Ajax to ASP.NET MVC. I do the following to accomplish this:
var formData=new FormData();
formData.Append("uploadedFile",$('input[type="file"]')[0].files[0]);
$.ajax({
url: "/Test/TestFormData",
data: formData,
cache: false,
contentType: false,
processData: false,
dataType:"json",
type: 'POST'
});
I couldn't figure out how to handle this on the server side with proper model binding (if that's ever possible) so I decided to go by searching Form by keys:
public class TestControler:Controller
public void TestFormData(){
var file=Request.Form["uploadedFile"];//file is null here
}
The problem is the file
is null when I try to access it. Here's the Request Headers and Payload:
Is there anything additional I have to do to get the file on the server side?