public ActionResult saveFile() { if (Request.Files["file"] != null) { var uniqueName = ""; FileDTO f = new FileDTO(); var file = Request.Files["file"]; if (file.FileName != "") { var ext = System.IO.Path.GetExtension(file.FileName); f.fileExt = ext; f.fileSizeInKb = file.ContentLength / 1000; f.uploadedOn = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); f.IsActive = true; f.parentFolderId = Convert.ToInt32(Session["pid"]); uniqueName = Guid.NewGuid().ToString() + ext; f.fileName = uniqueName; var rootPath = Server.MapPath("~/UploadedFiles"); var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName); file.SaveAs(fileSavePath); // Session["image"] = uniqueName; } FileDAO.Save(f); } return(Redirect("~/Users/Folder")); }
public static int Save(FileDTO dto) { return(FileDAO.Save(dto)); }