private void ImageUploadToServer() { HttpPostedFileBase file = Request.Files["fileUpload"]; if (string.IsNullOrEmpty(file.FileName)) { throw new Exception("Please select a file!"); } ImageController ic = new ImageController(); string savePath = "../images/UploadFiles"; string filePath = Path.Combine(HttpContext.Server.MapPath(savePath), Path.GetFileName(file.FileName)); UploadFile uploadFile = ic.ImageUpload(file, filePath, savePath); ViewData["CurrentUploadFile"] = uploadFile; }
private UploadFile ImageUploadToServer(int productID) { HttpPostedFileBase file = Request.Files["fileUpload"]; if (string.IsNullOrEmpty(file.FileName)) { throw new Exception("Please select a file!"); } string savePath = "../images/SMProducts"; if (productID > 0) { savePath = "../" + savePath; } string filePath = Path.Combine(HttpContext.Server.MapPath(savePath), Path.GetFileName(file.FileName)); ImageController ic = new ImageController(); UploadFile uploadFile = ic.ImageUpload(file, filePath, savePath); ViewData["CurrentUploadFile"] = uploadFile; return(uploadFile); }