/// <summary> /// 用户上传商品 /// </summary> /// <returns></returns> public ActionResult UploadGood() { ViewModel.UpLoadGoodModel model = new ViewModel.UpLoadGoodModel(); model.shopId = new ClassLibrary.MarketDownstairs().GetNowMallID(User.Identity.Name); return(View(model)); }
public ActionResult UploadGood(ViewModel.UpLoadGoodModel uploadModel, HttpPostedFileBase image) { //if (image != null) //{ // string upLoadPath = Server.MapPath("~/Content/Images/"); // Random rn = new Random(); // string unique = rn.Next(1000).ToString(); // string fileName = uploadModel.GoodName + unique + System.IO.Path.GetExtension(image.FileName); // ///获取存储物理路径 // string fileAdress = upLoadPath + fileName; // string photoAdress = "/content/Images/" + fileName; // image.SaveAs(fileAdress); ///获取提交上来的图片路径 string photoAddress = Request.Form["imageAddress"]; if (photoAddress != null) { bool flag = new ClassLibrary.MarketDownstairs().UpLoadGoodInfo(uploadModel, photoAddress); if (flag) { return(RedirectToAction("MarketIndex")); } else { return(View(uploadModel)); } } else { return(View(uploadModel)); } //} //else //{ // return View(uploadModel); //} }