2015-05-07 54 views
0

請幫助過濾圖片類型上傳,我已經做了一些試驗和錯誤,但不能得到它的工作。這裏是我的代碼:Dropzone acceptedFiles錯誤

$(document).ready(function(){ 

    Dropzone.autoDiscover = false; 
    var myDropzone = new Dropzone("#mydropzone",{ 
     url:"upload.php", 
     uploadMultiple: true, 
     maxFilesize: 2, 
     maxFiles : 3, 
     acceptedFiles: ".jpg,.jpeg,.png", <-- this won't work 
     dictInvalidFileType: "You can't upload files of this type, only png or jpg file", 
     autoProcessQueue : true, 
     parallelUploads: 3, 
     addRemoveLinks: true, 
    }); 
}); 

我已經試過:

acceptedFiles: "image/jpg,image/jpeg,image/png", 

但仍處於directory..if沒有上傳我刪除了逗號:

acceptedFiles: ".jpg,.jpeg,.png" 

它的工作,上傳顯示在我的目錄文件夾,但它接受所有類型的上傳..有什麼樣的訂購,使這項工作?任何人都可以幫忙嗎?

回答

1

試試:

$(function(){ 
    // Dropzone.autoDiscover = false; <-- You don't need it, remove it! 
    Dropzone.options.mydropzone = { <!-- string mydropzone is the form id 
     url:"upload.php", <-- Put this in form action 
     acceptedFiles: "image/jpeg,image/png", <-- jpeg = jpeg/jpg 
     // the other options... 
    }; 
}); 

希望幫助:)

0

可以在初始化函數工作

 var myDropzone = new Dropzone("#designdocumentexcel", 
      { 
       acceptedFiles : ".xls,.xlsx,.csv", 
       init: function(){ 
        this.on("error", function(file, errorMessage) { 
         alert("error : " + errorMessage); 
        }); 

       }, 
      } 
     );