2014-11-14 124 views
0

我試圖將Dropzone.js裝入自定義CMS。我在PHP中根據需要處理文件沒有問題,這實際上很簡單。Dropzone.js - 設置基本參數

我需要知道如何做到以下幾點上頁逐頁(將使用懸浮窗腳本在幾頁不同的功能):

  1. 限制的文件類型(JPG,JPEG, PDF)
  2. 限制,可以上傳的文件數量(某些頁面將 只是一個文件,有的會高達100)
  3. 限制最大文件大小
  4. 重定向的頁面或者有「下一個'當文件出現按鈕/鏈接時10上傳完成。

我可以添加此頁面的底部,同時解決了設置:

<script src="../assets/global/plugins/dropzone/dropzone.js"></script> 
<script> 
jQuery(document).ready(function() { 
    // initiate layout and plugins 
    Metronic.init(); // init metronic core components 
    Layout.init(); // init current layout 
    Demo.init(); // init demo features 
    FormDropzone.init(); 
}); 
</script> 

回答

0

HTML:

<div id="my-dropzone"></div> 

的JavaScript:

var initDropzone = function(filesAllowed){ 

    Dropzone.options.myDropzone = { 

     paramName: "file", 
     uploadMultiple: true, 
     maxFiles: filesAllowed, //this will need to be set upon init, 
     acceptedFiles: ['image/jpeg', 'image/jpg', 'application/pdf'], 
     complete: function() { 
      alert('Your file was successfully uploaded!'); 
     } 

    }; 
} 

//init the dropzone 
initDropzone(4);