How to not let the file name be overwritten, in dropzone.js

I’m using dropzone js successfully to upload files from a web page.
However, if a file gets uploaded that has the same name as a file already in the destination folder, it will overwrite the existing folder file.

I tried to remedy this by adding the js script function as shown below, but it didn’t work:

<div id="dropzone">
<form action="/uploadDrop.php" class="dropzone"></form>
</div>
 
<script type="text/javascript">
Dropzone.autoDiscover = false;
$(document).ready(function () {
    $(".dropzone").dropzone({
        renameFilename: function (filename) {
            return new Date().getTime() + '_' + filename;
        }
    });
});
</script>

Any help with this will be appreciated.

Dropzone uses a different rename method depending on the version of it that you’re using.
What version of Dropzone are you using?

Thanks for your reply.
Where would I find the version?
I’ve looked in readMe file and License file

That’s in the Dropzone.js file, as a variable called Dropzone.version

Or, you can issue the command Dropzone.version from the browser console to find out.

Thanks for your help.
in dropzone.js it shows:
Dropzone.version = “5.2.0”;

You’ll see on the Dropzone usage page that renameFilename has been deprecated, and that you should use a different technique instead.

Thanks for your reply.
Can you help with a “different technique”?

I don’t want to just quote verbatim from the websites documentation. Please go and read what it says there about renameFilename

What the documentation says, is that renameFile is used instead which doesn’t receive the filename, but a file object instead that has different keys that contain different details about the file, including its name. Information about how to use that file object is found in the Dropzone usage documentation.

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