Helo Freinds
I had a doubt in what is passing from view to controller
In my controller i give like this
public ActionResult Details(byte[] data)
{
Image g = new Image();
g.Img = data;
try
{
this.dbContext.Add(g);
this.dbContext.SaveChanges();
}
catch
{
return View();
}
var str = new { st = "saved" };
return Json(str, JsonRequestBehavior.AllowGet);
}
In my view define
<input type="file" id="photos">
by using file id am passing data.So in what format the controller received that data
My view file looks like this:
$("#save").click(function (event) {
alert("hai");
$.ajax({
type: "POST",
url: '/Home/Details',
data: $('#photos').load(url),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (str) {
alert("hai");
alert(str.st);
}
});
});
by using this syntax
data:$('#photos').load(url)
so in data what is there i mean path or file.In my database fields are Id(int), img(LongBlob) so my code is not working please help provide me any suggestions or code to find out the solution....