public ActionResult AddPhoto(int pId, List <HttpPostedFileBase> photo) { if (photo.Count <= 0) { return(RedirectToAction("ProductDetails", "Admin", new { id = pId })); } foreach (var item in photo) { var fileName = Guid.NewGuid() + "_" + item.FileName; var filePath = Server.MapPath("/Content/img/goods/UploadsImages"); var fullPath = Path.Combine(filePath, fileName); item.SaveAs(fullPath); var phot = new ProductImage { Product = _admin.GetProduct(pId), Path = "/Content/img/goods/UploadsImages/" + fileName, PhotoType = PhotoType.Photo }; _admin.AddPhoto(phot); } return(RedirectToAction("ProductDetails", "Admin", new { id = pId })); }