I have a view where I add products to a simple web store. I want to have several images with one product. Therefore, I use FileUpload from Microsoft.Web.Helpers. Using FileUpload in my view is as follows:
@FileUpload.GetHtml("Upload", 5, true, true, addText: "Add more", uploadText: "Upload files")
Then I have some labels and fields for other product attributes, for example:
<div class="editor-field"><br> @Html.EditorFor(model => model.Title)<br> @Html.ValidationMessageFor(model => model.Title)<br> </div>
The problem is that when I use the post method, my controller does not receive anything. I use the controller as follows:
[HttpPost] public ActionResult Create(Product product, IEnumerable<HttpPostedFileBase> fileUpload) { foreach (var file in fileUpload) { var fileName = Path.GetFileName(file.FileName); } return RedirectToAction("Index"); }
So, does anyone know what I'm doing wrong. Since my FileUpload object is always empty.
source share