public ActionResult Create(Product product, IEnumerable <HttpPostedFileBase> images) { ProductImage objProductImage = new ProductImage(); if (ModelState.IsValid) { objProductBO.InsertProduct(product); foreach (HttpPostedFileBase img in images) { string imageName = System.IO.Path.GetFileName(img.FileName); img.SaveAs(Server.MapPath("~/Images/" + imageName)); objProductImage.FKProductId = product.PKProductId; objProductImage.ImageName = imageName; objProductImage.ImagePath = "/Images/" + imageName; objProductImageBO.InsertImage(objProductImage); } return(RedirectToAction("Index")); } ViewBag.FKCategoryId = new SelectList(objCategoryBO.GetCategories(true), "PKCategoryId", "CategoryName"); ViewBag.FKSubCategoryId = new SelectList(objSubCategoryBO.GetSubCategories(0, true), "PKSubCategoryId", "SubCategoryName"); return(View(product)); }