Reputation: 384
I search so much for my problem, it seems so easy but did not get correct answer.
Here is my HTML Code
<input type="file" name="smallImage" id="smallImage" />
<input type="file" name="largeImage" id="largeImage" />
I can get files with Request.Files
, but it does not give me the HTML file input
info which the file is coming from.
As you see, I must understand which file input element sends the file.
Edit: I try this but did not work also
Request.Files["smallImage"]
Upvotes: 0
Views: 58
Reputation: 218752
You should use 2 arguments of type HttpPostedFileBase
in your HttpPost action method with same name as of your input field(s).
[HttpPost]
public ActionResult Create(HttpPostedFileBase smallImage,
HttpPostedFileBase largeImage)
{
// check smallImage & largeImage here
// to do : Return something
}
Assuming your form action value is set to this action method
@using (Html.BeginForm("Create", "YourControllerName", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
<input type="file" name="smallImage" />
<input type="file" name="largeImage" />
<input type="submit" />
}
Upvotes: 3