我在一个表单中有文本输入字段和多个文件上传。直到运行时我才知道文件或其他字段的数量。
<form action="/WorkOrder/Install" enctype="multipart/form-data" method="post">
<div class="display-label">
Description
</div>
<input id="description" name="description" type="text" value="" />
<div class="display-label">
Photo - Before Install
</div>
<input name="files" id="file1" type="file" />
<div class="display-label">
Photo - After Install
</div>
<input name="files" id="file2" type="file" />
<input type="submit"/>
</form>
正在填充 FormCollection,但 HttpPostedFileBase 集合始终为 null。 Request.Files 为空。
[HttpPost]
public ActionResult Install(FormCollection formCollection, IEnumerable<HttpPostedFileBase> files)
{
return View();
}
我尝试只有一个文件输入并更改 Controller 以接受单个 HttpPostedFileBase,问题是相同的。
最佳答案
jQuery Mobile 正在尝试处理表单提交。我必须在表单上设置 data-ajax="false"才能让 MVC Controller 处理文件上传。
关于jquery-mobile - MVC4 Controller 中的 IEnumerable<HttpPostedFileBase> 集合始终为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13423206/