I am using html5 FormData to send files to the server. However, the incoming photos object is always null. I can see the files being send in the network monitor. I think the type that i expect is wrong. Currently i have:
[HttpPost]
public JsonResult AssignImages(IEnumerable<HttpPostedFileBase> photos)
{
return new JsonResult();
}
I also tried:
[HttpPost]
public JsonResult AssignImages(IEnumerable<HttpPostedFile> photos)
{
return new JsonResult();
}
My JS:
function sendFileToServer(formData, status) {
var uploadURL = "/Inventory/AssignImages"; //Upload URL
$.ajax({
url: uploadURL,
type: "POST",
contentType: false,
processData: false,
cache: false,
data: formData,
success: function (data) {
}
});
function handleFileUpload(files){
var fd = new FormData();
for (var i = 0; i < files.length; i++) {
fd.append('File', files[i]);
sendFileToServer(fd, status);
}
}