我打算在同一视图中使用ajax和表单提交添加文件上传
@model project_name.Models.ProductFinanceFeatures
@{
}
<h2>--------File_Upload-------------</h2>
@using (Ajax.BeginForm("Financing_Product_Feature_Upload", "FileUpload", new { enctype = "multipart/form-data" }, new AjaxOptions() { HttpMethod = "POST" }))
{
@Html.AntiForgeryToken()
<input type="file" name="files">
<input type="submit" value="Upload File to Server">
}
<h2>-------Form_Submission-----</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
......
</div>
}
这是我的ajax控制器类方法
[HttpPost]
public ActionResult Financing_Product_Feature_Upload(HttpPostedFileBase files)
{
...
}
一旦我选择了一个文件并单击“上传”按钮,然后我调试了这个我可以看到files
值变为null