Multiple Dropzone on a single page

JavaScript

I want to create multiple Dropzone (Dropzone.js) on a single page. But I'm getting this error:

Dropzone already attached.		

Thats what I tried so far:

var firstDropZone = new Dropzone(document.body, {url: '/upload'});
var secondDropZone = new Dropzone(document.body, {url: '/upload'});
HTML Software OpenSource Question created: 2020-05-17 08:29 CleverMan

1

This is possible by creating multiple form elements and bind the Dropzone manually on it. You have to add a unique “id” to your form elements. Please note: You cannot bind multiple Dropzones on the same element like you tried:

HTML

<form action="/upload" class="dropzone" id="first"></form>
<form action="/upload" class="dropzone" id="second"></form>

JavaScript

var firstDropZone = new Dropzone('#first', {
    url: '/upload'
});

var secondDropZone = new Dropzone('#second', {
    url: '/upload'
});
answered 2020-05-17 08:35 codeBrother