2017-05-12 111 views
1

我想按鈕上單擊上傳文件。Dropzone autoProcessQueue:假不工作

我跟着這麼多的教程/問題,如 Upload all files with a button,Dropzone.js post request in laravel 5.4。但沒有取得成功。

這是我的看法文件中的代碼,

<form action="{{ url('admin/candidate/file-upload') }}" method="post" class="dropzone" id="my-dropzone"> 
    {{ csrf_field() }} 
    <div class="dz-message"> 
     <h3>Drop images here or click to upload.</h3> 
    </div> 
</form> 

這是我的JS文件代碼(文件準備塊),

//DropZone - Drag and drop file upload 
Dropzone.options.myDropzone = { 
    // Prevents Dropzone from uploading dropped files immediately 
    autoProcessQueue: false, 

    init: function() { 
     var submitButton = document.querySelector("#submit-all") 
     myDropzone = this; // closure 

     submitButton.addEventListener("click", function() { 
      myDropzone.processQueue(); // Tell Dropzone to process all queued files. 
     }); 
     // You might want to show the submit button only when 
     // files are dropped here: 
     this.on("addedfile", function() { 
      // Show submit button here and/or inform user to click it. 
     }); 
    } 
}; 

但我覺得我這個js文件塊不執行。應該是什麼問題?

+0

可以請簡要細節,什麼錯誤你得到的控制檯。 –

回答

0

我落在了同樣的情況,結果發現,代碼:

Dropzone.options.myDropzone = { .. } 

確實nothink有用。相反,我用:

Dropzone.forElement(".dropzone").options.autoProcessQueue = false; 

後,當我需要排隊我做的:

Dropzone.forElement(".dropzone").processQueue();