我的模特
public class Test
{
public string Name { get; set; }
public string Category { get; set; }
public HttpPostedFileBase ImageFile { get; set; }
}
我需要与其他字段一起发送文件。当我使用Dropzone时,ImageFile始终为null。 在视图中
@using (Html.BeginForm("Index", "Default", FormMethod.Post, new { enctype = "multipart/form-data",@class= "dropzone",id= "myDropzone" }))
{
@Html.LabelFor(p=>p.Name)
@Html.TextBoxFor(p=>p.Name)
@Html.LabelFor(p=>p.Category)
@Html.TextBoxFor(p=>p.Category)
@Html.LabelFor(p=>p.ImageFile)
<div class="fallback">
<input type="file" name="@Html.NameFor(p=>p.ImageFile)">
</div>
<input type="submit" id="submit-all" />
}
和dropzoe
Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
init: function () {
var submitButton = document.querySelector("#submit-all");
var myDropzone = this; //closure
submitButton.addEventListener("click", function () {
//tell Dropzone to process all queued files
myDropzone.processQueue();
});
}
};
可以将一个请求中的所有数据提交给一个操作吗?