Dropzone - Uncaught Error: No URL provided

Programming

I get the following error when I try to upload a file using Dropzone.js 

$("#my-dropzone").dropzone({
   maxFiles: 5000,
   url: "/ajax-file-handler/",
   success: function (file, response) {
      console.log(response);
   }
});

<form id="my-dropzone" 
      class=""  
      action=""
      enctype="multipart/form-data" method="post">
</form>

On file upload I get the following error in console:

Uncaught Error: No URL provided.
Computer Software Question created: 2020-04-13 11:34 ValdiBoom

3

Uncaught Error: No URL provided happens when a Dropzone gets attached to an object without an action attribute on a form or a JavaScript configuration for specific Dropzone.

This problem is caused if a Dropzone is attached to an element before  configuring it via JavaScript. Make sure that your configuration is after the JS import, or set Dropzone.autoDiscover = false; and instantiate the Dropzone manually.

<script type="text/javascript">

   Dropzone.autoDiscover = false;

   $(document).ready(function () {
        $("#my-dropzone").dropzone({
            maxFiles: 5000,
            url: "/ajax-file-handler/",
            success: function (file, response) {
                console.log(response);
            }
        });
   })

</script>

<form id="my-dropzone" 
      class="dropzone" 
      action="/ajax-file-handler/"
      enctype="multipart/form-data" 
      method="post">
</form>
answered 2020-04-13 16:15 SpelunkiRU