【发布时间】:2024-05-20 03:45:02
【问题描述】:
我的看法:
using (Ajax.BeginForm("Create", "CustomerEngagement", null, new AjaxOptions { OnSuccess = "closePopUpAndShowNextPost", InsertionMode = InsertionMode.Replace, HttpMethod = "post" }, new { @id = "create" }))
{
// Lots of things going on here
// I need to implement fileupload to upload attachments asynchronously here
<input name="fileupload1" id="fileupload1" multiple type="file" />
<button id="fileupload" name = "upload">
//Button to submit the form
<button id="save" value="save">
}
控制器:
[HttpPost]
public ActionResult Create(string word, StudentModel model)
{
List<string> synonyms = new List<string>();
List<string> sugg = new List<string>();
//Doing lot of stuff here
// I'm trying to get httppostedfilebase here but its null, also request.Files[] coming null.
}
我认为ajax.beginform中的文件没有上传,我们这里可以有其他解决方案吗?
【问题讨论】:
-
包含
new { enctype = "multipart/form-data" }html 属性 -
试过也不能用它
-
您无法使用 AJAX 上传文件 - *.com/questions/17037948/…
标签: jquery asp.net-mvc-4 asp.net-ajax asyncfileupload