C# 如何上传多个文件MVC 3
我需要从MVC3上传多个文件。但是我没有在服务器上获取变量。这是我的密码C# 如何上传多个文件MVC 3,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,我需要从MVC3上传多个文件。但是我没有在服务器上获取变量。这是我的密码 @using (Html.BeginForm("Index","Register", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.ValidationSummary(true) <table> <tr> <
@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>
}
@使用(Html.BeginForm(“Index”,“Register”,FormMethod.Post,new{enctype=“multipart/formdata”})){
@Html.ValidationSummary(true)
@Resources.Global.exampleofotos
}
控制器:
[HttpPost] public ActionResult Index(IEnumerable<HttpPostedFileBase> fileUpload, FormCollection collection)
{
return View();
}
[HttpPost]公共操作结果索引(IEnumerable文件上载,FormCollection集合)
{
返回视图();
}
但是fileUpload==Null 将输入的名称更改为fileUpload。您的文件输入名为file。然后,您正在寻找文件上载以填充IEnumerable文件。就个人而言,为了实现跨浏览器兼容性,我将使用以下答案:
基本上就是克隆你的文件上传输入每当有人在上次克隆的文件上传输入中选择一个文件时伙计,你真是个天才!谢谢,没问题。一般来说,如果你在上传文件,我喜欢控制。有什么我可以添加到这个答案来帮助你吗?你的问题解决了吗。如果是这样,你能接受答案吗:)这是一个很好的解决方案