/*上传明细*/ public ActionResult FileUpLoadDetail(HttpPostedFileBase imageUpLoad) { try{ List<ShangJia_ShangPin_DetailInfo> list = new List<ShangJia_ShangPin_DetailInfo>(); string fileName = imageUpLoad.FileName; string expandName = fileName.Substring(fileName.LastIndexOf('.') + 1); Guid guid = Guid.NewGuid(); var saveFileName = guid + "." + expandName; var shangpinid = Request["ShangPinId"]; var mendianid = Request["MenDianId"]; var saveOrgPath = System.Web.Configuration.WebConfigurationManager.AppSettings["WebOrgImgRealPath"];//;WebOrgImgRealPath //原图 var savePath = saveOrgPath + shangpinid;//物理路径 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } //保存到相对路径下。 var saveFilePath = savePath + "/" + saveFileName; imageUpLoad.SaveAs(saveFilePath); //缩小图 var saveRootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["WebImgRealPath"]; var saveSmallPath = saveRootPath + shangpinid;//物理路径 if (!System.IO.Directory.Exists(saveSmallPath)) { System.IO.Directory.CreateDirectory(saveSmallPath); } var saveSmallFilePath = saveSmallPath + "/" + saveFileName; ImageSmall.MakeThumbnail(saveFilePath, saveSmallFilePath, 220, 220, "Cut"); ShangJia_ShangPin_DetailInfo model = new ShangJia_ShangPin_DetailInfo(); model.ImgName = saveFileName; int spid = 0; int.TryParse(shangpinid, out spid); model.ShangPinId = spid; int mdid = 0; int.TryParse(mendianid, out mdid); model.MenDianId = mdid; list.Add(model); iopshelves.SaveShangJia_ShangPin_DetailInfo(list); //return RedirectToAction("action","controller",new {参数1=xx,参数2=xxx}) return RedirectToAction("UploadDetailImage", "Shelves", new { ShangPinId = shangpinid, MenDianId=mendianid }); } catch (Exception ex) { return RedirectToAction("UploadDetailImage"); } }
public ActionResult FileUpLoad(HttpPostedFileBase imageUpLoad) { try { var width = Request["imgWidth"]; int w; int.TryParse(width, out w); var heith = Request["imgHeigth"]; int h; int.TryParse(heith, out h); List <ShangJia_ShangPin_TuCe> list = new List <ShangJia_ShangPin_TuCe>(); string fileName = imageUpLoad.FileName; string expandName = fileName.Substring(fileName.LastIndexOf('.') + 1); Guid guid = Guid.NewGuid(); var saveFileName = guid + "." + expandName; var saveOrgPath = System.Web.Configuration.WebConfigurationManager.AppSettings["WebOrgImgRealPath"] + "test\\"; //;WebOrgImgRealPath //原图 var savePath = saveOrgPath; //物理路径 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } //保存到相对路径下。 var saveFilePath = savePath + "/" + saveFileName; imageUpLoad.SaveAs(saveFilePath); //缩小图 var saveRootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["WebImgRealPath"] + "test\\"; var saveSmallPath = saveRootPath;//物理路径 if (!System.IO.Directory.Exists(saveSmallPath)) { System.IO.Directory.CreateDirectory(saveSmallPath); } var saveSmallFilePath = saveSmallPath + "/" + saveFileName; ImageSmall.MakeThumbnail(saveFilePath, saveSmallFilePath, w, h, "HW"); return(Content("OK")); } catch (Exception ex) { return(RedirectToAction("UploadImage")); } }