Reputation: 7291
I'm trying to upload multiple image to server. HTML-
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" multiple />
<input type="text" name="caption"/>
<textarea name="description"></textarea>
<input type="submit" value="Submit" />
</form>
I'm able to handle single file. Here is my code-
public ActionResult SubmitImage(FormCollection data)
{
var file = Request.Files["file"];
}
How can I handle multiple files in server?
Upvotes: 3
Views: 6905
Reputation: 396
try this-
public ActionResult SubmitImage(IEnumerable<HttpPostedFileBase> file,FormCollection data)
{
foreach (var f in file)
{
}
}
Upvotes: 3
Reputation: 2793
I believe you are misunderstanding what Request.Files contains and how to access multiple files from the Request. Here is a link that has an appropriate example for you: http://www.mikesdotnetting.com/article/125/asp-net-mvc-uploading-and-downloading-files
Hope this helps.
Upvotes: 0