public ActionResult Download(int hdnFileId) { FileModel foundFile = DBDataInteract.GetFileData(hdnFileId); if (foundFile != null) { return(this.File(foundFile.FileData, foundFile.ContentType, foundFile.FileName)); } return(new EmptyResult()); }
public ActionResult Upload(HttpPostedFileBase postedFile) { if (postedFile == null) { return(null); //same as returning empty result } BinaryReader reader = new BinaryReader(postedFile.InputStream); byte[] filedata = new Byte[postedFile.ContentLength]; reader.Read(filedata, 0, filedata.Length); FileModel newFile = new FileModel { FileName = postedFile.FileName, ContentType = postedFile.ContentType, FileData = filedata }; DBDataInteract.StoreFileData(newFile); return(RedirectToAction("Index")); }
// GET: FileUploadDownload public ActionResult Index() { IEnumerable <FileModel> fileInfo = DBDataInteract.GetFilesList(); return(View(fileInfo)); }