public ActionResult UploadImg(FormCollection form, HttpPostedFileBase file) { try { string filePathName = string.Empty; string localPath = string.Empty; localPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Upload/Images/"); if (Request.Files.Count == 0) { throw new Exception("请选择上传文件!"); } string ex = Path.GetExtension(file.FileName); filePathName = Guid.NewGuid().ToString("N") + ex; if (!System.IO.Directory.Exists(localPath)) { System.IO.Directory.CreateDirectory(localPath); } string imgAddress = Path.Combine(localPath, filePathName); file.SaveAs(imgAddress); FileHelper.AddWaterText(imgAddress, "编码:30GAA02AA010$名称:#2澄清池润滑水进水阀$时间:" + DateTime.Now + "", imgAddress, 255, 14); return(Json(new { Status = 200, Message = "上传图片成功!", Data = localPath })); } catch (Exception) { //扔出异常 throw; } }