使用dropzone与其他输入一起提交文件

时间:2018-02-10 10:57:53

标签: javascript asp.net-mvc dropzone.js

我的模特

 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();
                });

            }

        };

可以将一个请求中的所有数据提交给一个操作吗?

0 个答案:

没有答案