Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- public WrappedJsonResult UploadImage(HttpPostedFileWrapper imageFile)
- {
- if (imageFile == null || imageFile.ContentLength == 0)
- {
- return new WrappedJsonResult
- {
- Data = new
- {
- IsValid = false,
- Message = "No file was uploaded.",
- ImagePath = string.Empty
- }
- };
- }
- var fileName = String.Format("{0}.jpg", Guid.NewGuid().ToString());
- var imagePath = Path.Combine(Server.MapPath(Url.Content("~/Content/imgs/product")), fileName);
- imageFile.SaveAs(imagePath);
- return new WrappedJsonResult
- {
- Data = new
- {
- IsValid = true,
- Message = string.Empty,
- ImagePath = Url.Content(String.Format("~/Content/imgs/product/{0}", fileName))
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement