forked from dropzone/dropzone
-
Notifications
You must be signed in to change notification settings - Fork 0
Remove all files with one button
Matias Meno edited this page Jun 20, 2013
·
5 revisions
This tutorial shows you how to create a button that will remove all files from a dropzone.
<form id="my-dropzone" action="/target-url" class="dropzone"></form>
<button id="clear-dropzone">Clear Dropzone</button>
<script language="javascript">
// myDropzone is the configuration for the element that has an id attribute
// with the value my-dropzone or myDropzone
Dropzone.options.myDropzone = {
init: function() {
this.on("sending", function(file) {
alert('Sending the file' + file.name)
});
// Using a closure.
var _this = this;
// Setup the observer for the button.
document.querySelector("button#clear-dropzone").addEventObserver("click", function() {
// Using "_this" here, because "this" doesn't point to the dropzone anymore
_this.removeAllFiles();
// If you want to cancel uploads as well, you
// could also call _this.removeAllFiles(true);
});
}
};
</script>Thanks to @trinione
- Dropzone already attached
- Large files not uploading
- Some image thumbnails aren't generated
- Show error returned by server
- Notification when all files finished uploading
- Add button to remove file preview
- Submit additional data
- Show info after file uploaded
- Show files already on server
- Use own
confirmimplementation - Limit the number of files
- Provide a thumbnail for files
- Reject images based on dimensions
Tutorials