public ActionResult WriteReview(Review review, HttpPostedFileBase[] images) { Customer thisUser = (Customer)Session["loggedInUser"]; if (custService.PostReview(review, thisUser.Id) >= 1) { foreach (HttpPostedFileBase file in images) { //Checking file is available to save. if (file != null) { string inputFileName = "image/reviews/" + custService.GetImageId().ToString() + Path.GetExtension(file.FileName).ToString(); custService.AddReviewImage(inputFileName); var serverSavePath = Path.Combine(Server.MapPath("~/") + inputFileName); //Save file to server folder file.SaveAs(serverSavePath); //assigning file uploaded status to ViewBag for showing message to user. ViewBag.UploadStatus = images.Count().ToString() + " files uploaded successfully."; } } } return(View()); }