2015-01-16 49 views
3

我將「正常」形式與dropzone組合起來存在問題。我有一個帶有文本輸入,文件輸入和dropzone部分的表單。我想要立即發佈所有內容。所以我正在手動創建dropzone字段,我正在禁用dropzone的autoProcessQueue功能並綁定到onClick的提交按鈕。將常規形式與文件輸入結合起來使用dropzone

<form action="/Exhibits/Create" enctype="multipart/form-data" id="newExhibitForm" method="post"> 
    <input id="Exhibit_Name" name="Exhibit.Name" type="text" 
    <input id="Exhibit_Description" name="Exhibit.Description" type="text"> 

    <input id="ModelFile" name="ModelFile" type="file"> 
    <input id="TextureFile" name="TextureFile" type="file"> 

    <div id="dropzonePreview" class="dropzone-previews form-control dz-clickable"> 
     <div class="dz-message">Drag&drop</div> 
    </div> 

    <input type="submit" value="Create" class="btn btn-default"> 
</form> 

JS部分:

var photoDropzone = new Dropzone("#newExhibitForm", { 
    url: $('#newExhibitForm').attr("action"), 
    autoProcessQueue: false, 
    uploadMultiple: true, 
    parallelUploads: 10, 
    maxFiles: 10, 
    previewsContainer: '#dropzonePreview', 
    clickable: '#dropzonePreview', 

    // The setting up of the dropzone 
    init: function() { 
     var myDropzone = this; 

     var submitButton = document.querySelector('input[type=submit]'); 
     myDropzone = this; // closure 

     submitButton.addEventListener("click", function (e) { 
      e.preventDefault(); 
      e.stopPropagation(); 
      if (myDropzone.getQueuedFiles().length === 0) { 
       $('#newExhibitForm').submit(); 
      } 
      else { 
       myDropzone.processQueue(); 
      } 
     }); 
    } 
}); 

當我提交表單點擊提交按鈕,在服務器端的功能有懸浮窗文件,文本輸入,但文件輸入不發送。

有沒有辦法讓它在開始時描述的方式工作?

問候,
康拉德

回答

0

我很抱歉,但在當時,每個文件被單獨上傳。因此,您需要將文件分別存儲在服務器上,然後當dropzone發出事件時,您將發送剩餘的輸入字段。

相關問題