public JsonResult Upload(string dataID, string frmID, string field, string typecode) { try { FBFileSave model = new FBFileSave(); model.ID = Guid.NewGuid().ToString(); HttpPostedFileBase file = Request.Files["file"]; if (file != null) { model.DataID = dataID; model.FrmID = frmID; model.FileName = file.FileName; model.TypeCode = typecode; var res = _service.saveFile(model, StreamToBytes(file.InputStream)); if (!string.IsNullOrEmpty(res)) { model.ID = res; } } else { throw new Exception("未获取到文件信息!"); } return(Json(new { res = true, data = model.ID })); } catch (Exception ex) { log.Error(ex); return(Json(new { res = false, mes = "上传失败" + ex.Message })); //throw ex; } }
public JsonResult Upload(string dataID, string frmID, string field) { try { FBFileSave model = new FBFileSave(); model.ID = Guid.NewGuid().ToString(); HttpPostedFileBase file = Request.Files["file"]; if (file != null) { model.DataID = dataID; model.FrmID = frmID; model.FileName = file.FileName; _service.saveFile(model); } else { throw new Exception("未获取到文件信息!"); } return(Json(new { res = true, data = model.ID })); } catch (Exception ex) { log.Error(ex); return(Json(new { res = false, mes = "上传失败" + ex.Message })); //throw ex; } }