public JsonResult ProductAddPhoto(int id) { var file = Request.Files.Get("myfile"); var uploader = new FileUploader(file); var result = new { filename = uploader.Name, contentType = uploader.ContentType, contentLength = uploader.ContentLength, newFilename = uploader.UniqueName }; try { uploader.Save("products"); _productImageRepository.Save(new ProductImage() { ProductId = id, Link = uploader.UniqueName }); } catch (Exception) { return(Json(new { status = "fail" }, "text/html")); } return(Json(result, "text/html")); }