我可以用吗:
<input type="file" name="files" id="files" multiple="multiple" />
Run Code Online (Sandbox Code Playgroud)
并将其绑定到:
[HttpPost]
public ActionResult Upload(IEnumerable<HttpPostedFileBase> files)
{
...
}
Run Code Online (Sandbox Code Playgroud)
我正在为现代浏览器编写一个Web应用程序,不必担心IE,所以我想避免使用Flash.files当我发布表单时,现在总是为空.有什么方法可以让它在MVC 3中运行吗?
谢谢!
Gat*_*ats 13
您是否在表单中正确设置了编码?
我相信你还需要:
new { enctype = "multipart/form-data" }
Run Code Online (Sandbox Code Playgroud)
在表单声明中确保浏览器可以发布文件.
例如:
@using (Html.BeginForm("action", "controller", FormMethod.Post, new { enctype = "multipart/form-data" }))
Run Code Online (Sandbox Code Playgroud)