Dropzone - Error Opening: No URL

I cannot figure out how to get JSONresponse after uploading a file using Dropzonejs.

I have only this:

<script src="{% static "dropzone/dropzone.js" %}"></script> <form id="id_dropzone" class="dropzone" action="/ajax_file_upload_handler/" enctype="multipart/form-data" method="post"></form> 

I think this is not possible without manually initializing dropzone, so I changed it to:

 $("#id_dropzone").dropzone({ maxFiles: 2000, url: "/ajax_file_upload_handler/", success: function (file, response) { console.log(response); } }); <form id="id_dropzone" class="" action="" enctype="multipart/form-data" method="post"></form> 

What is the return of Uncaught Error: No URL provided.

How can I initialize dropzone to add parameters like maxFiles, maxSize and get a JSON response?

+5
source share
1 answer

A missing URL occurs when Dropzone binds to an object without:

  • attribute of the action in the form that tells dropzone where to send the message
  • configuration for specific dropzone

My bet is that you have a race condition where Dropzone joins the element before you set it up. Make sure your configuration is either immediately after importing JS or Dropzone.autoDiscover = false; , and explicitly create Dropzone.

Check here for more information.

 <script src="{% static "dropzone/dropzone.js" %}"></script> <script type="text/javascript"> Dropzone.autoDiscover = false; $(document).ready(function () { $("#id_dropzone").dropzone({ maxFiles: 2000, url: "/ajax_file_upload_handler/", success: function (file, response) { console.log(response); } }); }) </script> <form id="id_dropzone" class="dropzone" action="/ajax_file_upload_handler/" enctype="multipart/form-data" method="post"> </form> 
+16
source

Source: https://habr.com/ru/post/1263718/


All Articles