I have the following client-side code to send a JSON object and a file to MVC using JQuery ajax:
var formData = new FormData();
formData.append('logo', logoImg);
var objArr = [];
objArr.push({"id": id, "name": userName});
//JSON obj
formData.append('ocorrencia', JSON.stringify( objArr ));
$.ajax({
url: "/Ocorrencia/Edit",
type:"POST",
processData:false,
contentType: false,
data: formData,
complete: function(data){
alert("success");
}
});
On the server-side, I'm using ASP.NET MVC.
[HttpPost]
public JsonResult Edit()
{
// How to retrieve the data and the file here?
I have a model to the "ocorrencia". What do I have to do to retrive the model and the file on the server side?