public async Task <IActionResult> SaveAs(IFormFile file, string pid) { var targetPath = Path.Combine(AppConsts.AppRootPath, "upload", "patient"); var targetHeadIconPath = Path.Combine(targetPath, "headIcon"); FileHelper.CreateDirectory(targetPath); FileHelper.CreateDirectory(targetHeadIconPath); var serialNo = Common.CreateNo(); var fileName = Path.Combine(targetPath, serialNo + Path.GetExtension(file.FileName)); using (var stream = new FileStream(fileName, FileMode.Create)) { await file.CopyToAsync(stream); stream.Flush(); } var headFileName = Path.Combine(targetHeadIconPath, serialNo + Path.GetExtension(file.FileName)); Ext.CutForSquare(fileName, headFileName, 400, 90); if (!pid.IsEmpty()) { var entity = await _patientApp.GetForm(pid); if (entity != null) { entity.F_HeadIcon = headFileName.Replace(AppConsts.AppRootPath, ""); await _patientApp.UpdateForm(entity); } } return(Success("上传图片成功")); }