1
我使用jquery upload file plugin上傳多個文件。我已經添加了CSS和JavaScript文件上傳參考。填充客戶名稱並添加一些文件附件後,我提交表單,但無法保存文件,因爲IEnumerable爲空。我做錯了什麼?使用jquery上傳文件插件上傳,IEnumerable <HttpPostedFileBase>不包含文件
查看
@using (Html.BeginForm()) {
@Html.LabelFor(model => model.Client)
@Html.DisplayFor(model => model.Client.Name)
<div id="fileuploader">Upload</div>
<input type="submit" value="Save" class="btn btn-default" />
}
@section Styles {
<link href="~/Content/uploadfile.css" rel="stylesheet">
}
@section Scripts {
<script src="~/Scripts/jquery.uploadfile.js"></script>
<script>
$(document).ready(function() {
$("#fileuploader").uploadFile({
url: "/Attachment/Upload/",
dragDrop: true,
multiple: true,
autoSubmit: false,
fileName: "myFile",
returnType: "json",
showDone: false,
showDelete: true,
deleteCallback: function (data, pd) {
for (var i = 0; i < data.length; i++) {
$.post("/Attachment/Delete/", { op: "delete", name: data[i] },
function (resp, textStatus, jqXHR) {
//Show Message
alert("File Deleted");
});
}
pd.statusbar.hide(); //You choice.
}
});
});
</script>
}
控制器
public ActionResult Edit(Client client, IEnumerable<HttpPostedFileBase> myFile) {
...
}