我正在尝试在ASP.NET MVC 5.2中使用Ajax.BeginForm()
上传文件。
查看:
@model EventsImages
@using (Ajax.BeginForm("Create", "EventsImages", new AjaxOptions { HttpMethod = "POST", OnComplete = "completeForm(xhr, status,'listDialog1')" }, new { enctype = "multipart/form-data", @class = "form", @role = "form" }))
{
<div class="col-md-12 col-sm-12">
@Html.AntiForgeryToken()
...
<input type="file" id="upload" name="upload" />
<input type="submit" value="Create" class="btn" />
控制器:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(EventsImages eventsImages, HttpPostedFileBase upload)
{
if (ModelState.IsValid)
{
问题是HttpPostedFileBase
上载始终为空。
我知道这个问题已经提到过几次了,但是我找不到解决方案或解决方法。