tags:

views:

1920

answers:

3

Is there a HTMLHelper for file upload? Specifically, I am looking for a replace of

<input type="file"/>

using ASP.NET MVC HTMLHelper.

Or, If I use

using (Html.BeginForm())

What is the HTML control for the file upload?

+2  A: 

I had this same question a while back and came across one of Scott Handelman's posts:

Implementing HTTP File Upload with ASP.NET MVC including Tests and Mocks

Hope this helps.

Dan Atkinson
Thanks, but I am specifically looking for an implementation of using (Html.BeginForm()), not other variants.
Ngu Soon Hui
+1  A: 

To use BeginForm, here's the way to use it:

 using(Html.BeginForm("uploadfiles", 
"home", FormMethod.POST, new Dictionary<string, object>(){{"type", "file"}})
Ngu Soon Hui
First you mention how to generate an input element, and now you talk about how to generate a form element? Is this really your answer?
J. Pablo Fernández
You are right; I have just edited my answer.
Ngu Soon Hui
http://stackoverflow.com/questions/216600/html-beginform-and-adding-properties
Zack Peterson
A: 

There's also a custom-made extension here.

neo