如何上传多个文件MVC 3



我需要从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>&nbsp;</td>
                   <td><input type="submit" value="@Resources.Global.enviar" /></td>
              </tr>
         </table>
    }

控制器:

[HttpPost] public ActionResult Index(IEnumerable<HttpPostedFileBase> fileUpload,  FormCollection collection)  
{
      return View();  
}

但是fileUpload==Null;

将输入名称更改为fileUpload。您的文件输入名称为file。然后,您正在寻找fileUpload来填充您的IEnumerable文件。

就我个人而言,为了实现跨浏览器兼容性,我会使用这个答案:使用MVC3 以相同的形式上传多个图像

每当有人在最后一个克隆的文件上传输入中选择一个文件时,它基本上就是克隆你的文件上传输出

最新更新