2014-09-26 907 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