2014-09-26 909 views
2

我使用dropzone.js將圖像上傳到我的php服務器。我已經使用jquery ajax調用來保存所有圖像上傳後的表單。上傳文件後重置Dropzone

現在,我想清除表單值保存在服務器上的dropzone div。我試過removeAllFiles(),但它也從服務器上刪除文件。

我GOOGLE了很多次,但沒有得到任何正確的想法。如果有人知道,請提供任何幫助。 在此先感謝!

+0

請問您能否提供HTML和JS代碼? – heroin 2014-09-26 08:54:12

+0

對不起@heroin但只是因爲安全原因,我不能這樣做.... – Jaspal 2014-09-26 08:59:45

+0

好,再一個可能的解決方案只是用來掩飾對應的文件,這些文件已經加載到服務器的那些標記元素。只需使用'display:none;''爲他們。可以嗎? – heroin 2014-09-26 09:02:24

回答

3

您可以將事件處理程序添加到dropzone的「queuecomplete」中。在這個處理程序中,做任何你想要的。在這個例子中,我重新加載了所有上傳的文件,以及removeAllFiles()。

Dropzone.options.myAwesomeDropzone = { 
    init: function(){ 
     var th = this; 
     this.on('queuecomplete', function(){ 
      ImageUpload.loadImage(); // CALL IMAGE LOADING HERE 
      setTimeout(function(){ 
       th.removeAllFiles(); 
      },5000); 
     }) 
    }, 
    paramName: "file", // The name that will be used to transfer the file 
    maxFilesize: 2, // MB  
    acceptedFiles: 'image/*', 

}; 
3
my.on("complete", function(file) { my.removeFile(file); }); 
my.on("complete", function(file) { my.removeAllFiles(file);}); 
+3

添加一個什麼樣的代碼做一些簡要的解釋。 – Ziumin 2014-12-29 09:02:59