Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix this "Dropzone already attached" error?

I have this sample:

link

I managed to create this form but unfortunately it does not work because I get error.

Dropzone already attached.

CODE HTML:

<div class="dropzone dz-clickable" id="myDrop">
  <div class="dz-default dz-message" data-dz-message="">
    <span>Drop files here to upload</span>
  </div>
</div>

CODE JS:

Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#myDrop", { url: "/file/post"});

// If you use jQuery, you can use the jQuery plugin Dropzone ships with:
$("div#myDrop").dropzone({ url: "/file/post" });

I set up Dropzone.autoDiscover = false; but unfortunately still not working.

Can you please tell me what is causing this problem?

like image 334
Marius Avatar asked Oct 12 '15 08:10

Marius


People also ask

How do I delete dropzone?

You can call removeAllFiles function to clear dropzone object before upload.So when ever you try to upload something using dropzone it will be always clear.

How do I change the default message in Dropzone?

If you are creating Dropzones Programmatically then you have to set your options like below: Dropzone. autoDiscover = false; profilePicture = new Dropzone('#profile-picture', { url: "/uploadPicture.

What is dropzone file upload?

js is one of the most popular drag and drop JavaScript libraries. It is free, fully open source, and makes it easy for you to handle dropped files on your website. It's meant to look good by default, and is highly customizable. Documentation Download.


Video Answer


2 Answers

Defining below code globally will help:

Dropzone.autoDiscover = false;
like image 193
Syed Avatar answered Oct 22 '22 10:10

Syed


You should use either

var myDropzone = new Dropzone("div#myDrop", { url: "/file/post"});

or

$("div#myDrop").dropzone({ url: "/file/post" });

not both. Basically what you are doing is calling the same thing twice.

like image 30
drys Avatar answered Oct 22 '22 09:10

drys