Dropzone
Search…
Imperative
How to create a Dropzone upload with JavaScript.
As an alternative to the declarative way, you can create Dropzones imperatively (even on non <form>elements) by instantiating the Dropzone class:
Plain JavaScript
jQuery
1
// The constructor of Dropzone accepts two arguments:
2
//
3
// 1. The selector for the HTML element that you want to add
4
// Dropzone to, the second
5
// 2. An (optional) object with the configuration
6
let myDropzone = new Dropzone("div#myId", { url: "/file/post"});
Copied!
1
// The dropzone method is added to jQuery elements and can
2
// be invoked with an (optional) configuration object.
3
$("div#myId").dropzone({ url: "/file/post" });
Copied!
Don’t forget to specify an url option if you’re not using a <form> element, since Dropzone doesn’t know where to post to without an action attribute. On form elements, Dropzone defaults to the action attribute.
For a list of all configuration options, refer to the configuration section.
Copy link