/// <summary> /// 上传图片 /// </summary> /// <returns></returns> public ActionResult UploadImage(string uploadId) { var hfc = this.HttpContext.Request.Files; if (hfc.Count > 0) { var file = hfc[0]; string savePath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, PIC_PATH); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } string pic = Path.GetExtension(file.FileName); var fileName = Guid.NewGuid().ToString() + pic; var path = Path.Combine(savePath, fileName); file.SaveAs(path); docMgr.AddAtachFile(uploadId, 0, path); var relativePath = string.Format("{0}/{1}/{2}", HostingEnvironment.ApplicationVirtualPath.TrimEnd('/') , PIC_PATH.TrimEnd('/') , fileName); var result = new { success = 1, message = "", url = relativePath }; return(Json(result)); } return(Json(new { success = 0, message = "", url = "" })); }