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
You could implement an action with POST http verb to that receive a collection of HttpPostedFileBase and save all files, for sample:
[HttpPost]
public ActionResult Upload(IEnumerable files)
{
foreach (var file in files)
{
file.SaveAs(Server.MapPath("~/Update/" + file.FileName));
}
return View();
}
Alternatively, you could read Request.Files and do the same job,
[HttpPost]
public ActionResult Upload()
{
foreach (var file in Request.Files)
{
file.SaveAs(Server.MapPath("~/Update/" + file.FileName));
}
return View();
}