is there a good example of how to upload multiple image files in asp.net mvc? I know we can use HttpPostedFileBase to upload one file. Is there a way to upload multiple file
Some of the basic bits required for file uploads
Notice keyword: multiple in input element AND multipart in form element
@using (Html.BeginForm("MyUpload", "MyController", FormMethod.Post, new { enctype = "multipart/form-data" })) {
}
[HttpPost]
public ActionResult MyUpload(IEnumerable myFiles)
{
foreach (var file in myFiles)
{
if (file != null && file.ContentLength > 0)
{
//handle files;
}
}
return View();
}