<script type="text/javascript"> $(document).ready(function () { $("#photos").kendoUpload(); $("#save").click(function (event) { alert("started"); url = 'Home/Details' var data = $('#photos').load(url) $.ajax({ type: "POST", url: '/Home/Details', //data: data, contentType: "application/json; charset=utf-8", dataType: "json", success: function (str) { alert("hai"); alert(str.st); } }); </script> <body> <input name="photos" id="photos" type="file" /> <input type="button" value="save" id="save" /> </body>
public ActionResult Details(HttpPostedFileBase data) { try { data = Request.Files[1]; byte[] imageSize = new byte[data.ContentLength]; data.InputStream.Read(imageSize, 0, (int)data.ContentLength); Image g = new Image(); g.Img = imageSize; dbContext.Add(g); dbContext.SaveChanges(); return RedirectToAction("Index"); } catch { } var str = new { st = "saved" }; return Json(str, JsonRequestBehavior.AllowGet); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)