Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear dropzone.js dropzone

Tags:

dropzone.js

I am starting to use dropzone.js and have run into a minor problem. I am able to upload files. I use a modal popup to get the file information.

The problem is when I go back the files I previously uploaded are still in the drop zone (with checkmarks). I want an empty dropzone.

Ideas?

like image 206
mlewis54 Avatar asked Jan 24 '15 21:01

mlewis54


People also ask

How do I remove all files from dropzone?

dropzone has the following function for removing all files. If you want to remove all files, simply use . removeAllFiles(). Files that are in the process of being uploaded won't be removed.

How does dropzone JS work?

Dropzone. js is 'a light weight JavaScript library that turns an HTML element into a "dropzone"'. Users can drag and drop a file onto an area of the page, uploading to a server. If you would like to read more how all of this works skim through the Dropzone.


1 Answers

All the answers I've seen involve assigning a variable when you initialize dropzone. If you don't want to do this extra step and already have your dropzone element: You can use Dropzone's forElement method to directly target your dropzone without the need for any variables:

Dropzone.forElement('#myDropzoneElementID').removeAllFiles(true)
like image 187
chevybow Avatar answered Sep 19 '22 20:09

chevybow