我能够将单个文件作为 System.Web.HttpPostedFileBase 传递,但是当我传递相同的文件数组时,我在控制器的操作中得到 null。
我试过发送文件数组。
HTML:
<input type="file" id="Attachment1">
<input type="file" id="Attachment2">
<input type="file" id="Attachment3">
<input type="file" id="Attachment4">
<input type="file" id="Attachment5">
Java脚本:
var FileData = [];
$('input').each(function () {
var type = $(this).attr("type");
if (type == "file") {
FileData.push($(this).get(0).files[0]);
}
});
var Data = new FormData();
Data.append("Attachments", FileData);
if (url != '') {
$.ajax({
url: url,
data: Data,
type: "POST",
contentType: false,
processData: false,
success: function (data) {
alert("Saved successfully");
}
});
}
控制器:
public ActionResult InsertDetails(System.Web.HttpPostedFileBase[] Attachments)
{
return Json(new { Success = false });
}
需要获取文件数组。提前致谢。
千巷猫影
慕尼黑的夜晚无繁华
qq_笑_17
相关分类