Help with redirect in dropzone.js

I was surfing to find some code to add to the dropzone script (that I’m using successfully), that would redirect after a file is uploaded. I found and added the script below, and it works successfully.

I have two questions - one is what is the auto discover feature? I’ve seen something that said ‘it scans the document for dropzone elements’, what does that mean ?

The other question is - can you help me add some code to delay the redirect, it’s so immediate. A slight delay would be an improvement.

Thanks for any help. Here’s the code:

<script type="text/javascript">
//Disabling autoDiscover
Dropzone.autoDiscover = false;
$(function() {
    //Dropzone class
    var myDropzone = new Dropzone(".dropzone");
    myDropzone.on("queuecomplete", function() {
        //Redirect URL
        window.location.href = 'http://.....';
    });
});
</script>

Normally when the page loads, Dropzone automatically discovers and sets up regions that can be used with it.

If you are going to programmatically create dropzone regions yourself, which you seem to be doing above, you need to tell Dropzone to not do it automatically, otherwise there will be two Dropzones attached to the one area, which wouldn’t be good.

When it comes to the redirect, place it in a setTimeout() function to delay it. For example, with a 1 second delay:

setTimeout(function () {
    window.location.href = 'http://.....';
}, 1000);

Thank you again

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.