public JsonResult DeleteImage(string imageFolderName, string fileName) { ViewModel.ReturnResult <bool> returnResult = new ViewModel.ReturnResult <bool>(); System.IO.File.Delete(Server.MapPath($"~/AkoSatrapImages/{imageFolderName}/{fileName}")); return(Json(returnResult)); }
public JsonResult GetProductImages(string imageFolderName) { ViewModel.ReturnResult <List <string> > returnResult = new ViewModel.ReturnResult <List <string> >(); var path = Server.MapPath($"~/AkoSatrapImages/{imageFolderName}/"); if (Directory.Exists(path)) { returnResult.Data = Directory.GetFiles(path).Select(r => Path.GetFileName(r)).ToList(); } return(Json(returnResult)); }
public JsonResult GetImages() { var returnResult = new ViewModel.ReturnResult <List <string> >(); var path = System.Web.Hosting.HostingEnvironment.MapPath($"~/AkoSatrapImages/abilities/"); if (Directory.Exists(path)) { returnResult.Data = new List <string>(); if (Directory.GetFiles(path).Any()) { returnResult.Data = Directory.GetFiles(path).Select(r => Path.GetFileName(r)).ToList(); } } return(Json(returnResult)); }
public JsonResult AddImage(FileAttachment fileAttachment, int id) { var returnResult = new ViewModel.ReturnResult <bool>(); if (fileAttachment.Attachment.ContentLength > 2097152) { returnResult.SetError("حجم فایل نمیتواند بیشتر از 2 مگابایت باشد"); return(Json(returnResult)); } var path = Server.MapPath($"~/AkoSatrapImages/abilities/"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } fileAttachment.Attachment.SaveAs($"{path}/{Guid.NewGuid()}.{fileAttachment.Attachment.FileName.Split('.')[1].ToString()}"); return(Json(returnResult)); }