public ActionResult LoadFile(int id) { string extension = null; using (Conector.Comon common = new Conector.Comon()) { extension = common.GetExtension(id); } return(File(global::System.IO.File.ReadAllBytes(Path.Combine(PathContent, id.ToString())), extension)); }
public JsonResult SaveFile() { HttpPostedFileBase file = Request.Files[0]; int FileId; using (Conector.Comon common = new Conector.Comon()) { FileId = common.SaveFile(Path.GetExtension(file.FileName)); MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); byte[] data = target.ToArray(); global::System.IO.File.WriteAllBytes(Path.Combine(PathContent, FileId.ToString()), data); } return(Json(new SaveFileResponse() { Id = FileId })); }