简体   繁体   中英

DropZone: “No URL provided” and “Dropzone already attached.”

I'm using dropzone and jquery. I have this code:

  <div id="my-image">
    <!-- .......... -->
  </div>

And

  <script type="text/javascript">
    Dropzone.autoDiscover = false;

    $(document).ready(function() {
      var image_uploader = new Dropzone("#upload-image", {url: "/image_uploader", acceptedFiles : "image/*",
                                                          maxFiles: 1, maxFilesize: 1, autoDiscover: false});

      //.................

And yet I have these 2 errors:

//dropzone.js:712
Uncaught Error: No URL provided.
    at new Dropzone (dropzone.js:712)
    at Function.Dropzone.discover (dropzone.js:1641)
    at Dropzone._autoDiscoverFunction (dropzone.js:1923)
    at HTMLDocument.init (dropzone.js:1892)

And:

//jquery-3.3.1.min.js:2

Uncaught Error: Dropzone already attached.
  at new Dropzone (dropzone.js:699)
  at HTMLDocument.<anonymous> ((index):221)
  at l (jquery-3.3.1.min.js:2)
  at c (jquery-3.3.1.min.js:2)

Why are they occuring? How to fix them?

For the first error you have to add Dropzone.autoDiscover = false; before $(document).ready(function (){})

For the second error I think you are declaring Dropzopne.js twice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM