4

I am using dropzone.js to uploads images to my php server. I have used jquery ajax call to save the form after all images are uploaded.

Now, i want to clear the dropzone div when form values are saved on the server. I have tried removeAllFiles() , but it removes files from server too.

I have googled so many times but not getting any right idea. Please provide any help if anyone knows . Thanks in advance!!!

5
  • Could you please provide HTML and JS code? Commented Sep 26, 2014 at 8:54
  • sorry @heroin but just because of security reasons, i can't do that.... Commented Sep 26, 2014 at 8:59
  • Ok, then one possible solution is just to hide those tag elements corresponding to files, which were already loaded to the server. Just use display: none; for them. Is it ok? Commented Sep 26, 2014 at 9:02
  • Actually, by default it should not delete files on a server. Look at the code: addRemoveLinks: true, removedfile: function(file) { var _ref; return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; } Commented Sep 26, 2014 at 9:09
  • thanks for your response, I have done my job by using a flag variable and checking the flag variable while using deleteAllFiles by not making a call to server... Commented Sep 29, 2014 at 3:43

2 Answers 2

5

You can add event handler to "queuecomplete" of the dropzone. In this handler, do whatever you want. In the example, I reload all uploaded files, and 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/*', }; 
Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Add some brief explanation of what your code is doing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.