public class Person{ [Required] public string Name {get;set;} public HttpPostedFileBase Photo{ get; set; } }
[HttpPost] public HttpResponseMessage Save(Person person) if (!ModelState.IsValid) { Request.CreateResponse(HttpStatusCode.BadRequest) } return Request.CreateResponse(HttpStatusCode.OK); }
And here is my doubt : How to configure the ajax call? With "?????" I show where are my doubts. <pre> function SaveImage(){ var ulr= 'http://localhost:5555/api/Uploader/'; var person = { Name : 'Donald', Photo : ????? //---> what hould I assign to photo? }; $.ajax({ url: url, method: "POST", data: person, cache: false, dataType: ???? , // json ?? contentType: ???? }).done(function (res) { alert('OK'); }) .fail(function (res) { alert('PROBLEMS!!'); }) }
FormData
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)