I have the following view model.
public class MyViewModel
{
[DataType(DataType.Upload)]
public HttpPostedFileBase ImageUpload { get; set; }
publ
I have another idea. How about getting rid of the HttpPostedFileBase from the model and from the controller either ?
In your html, you would add:
@using (Html.BeginForm("actionNameYouWriteToManupulate", "controllerYouWrite", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
...
}
Add Files as many files you want, and in the controller :
var hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
var hpf = hfc[i];
if (hpf.ContentLength > 0)
{
//Do what you want with files
//Handler pointed to file is hpf for example :
hpf.SaveAs(Server.MapPath(fullPathWithFileName));
}
}
Hope to be usefull.