gpt4 book ai didi

c# - 如何上传多个文件 MVC 3

转载 作者:行者123 更新时间:2023-11-30 15:05:17 25 4
gpt4 key购买 nike

我需要从 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>
}

Controller :

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

但是fileUpload == Null;

最佳答案

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

关于c# - 如何上传多个文件 MVC 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9162931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com