我需要从MVC3上传多个文件。但是我没有得到服务器上的变量。这是我的代码。
@using (Html.BeginForm("Index","Register", FormMethod.Post, new { enctype = "multipart/form-data" })) {
@Html.ValidationSummary(true)
<table>
<tr>
<td class="label">@Resources.Global.exemploFotos</td>
<td><input type="file" name="file" class="multi" accept="gif|jpg" maxlength="3" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="@Resources.Global.enviar" /></td>
</tr>
</table>
}控制器:
[HttpPost] public ActionResult Index(IEnumerable<HttpPostedFileBase> fileUpload, FormCollection collection)
{
return View();
}但fileUpload ==为空;
发布于 2012-02-06 23:56:42
将输入的名称更改为fileUpload。您的文件输入名称为file。然后,您将寻找fileUpload来填充您的IEnumerable文件。
发布于 2013-11-07 02:32:06
就我个人而言,为了实现跨浏览器的兼容性,我会使用这个答案:Uploading multiple images in the same form using MVC3
每当有人在最后一次克隆的文件上传输入中选择一个文件时,它基本上就是克隆你的文件上传输入
https://stackoverflow.com/questions/9162931
复制相似问题