Help with limiting the file extensions for uploading in dropzone.js

I’m using dropzone successfully for uploads, but want to limit what gets uploaded to, for example, just mp4 and png files.

In dropzone.js I changed this:

acceptedFiles: null,

to this:

acceptedFiles: video/mp4, image/png,

but still, other files are still uploading upon testing jpg, pdf, etc.

How/where can I limit what gets uploaded?

I look forward to any help…

I’ve never used it, but various searches suggest you should enclose the parameter in quotations:

acceptedFiles: "video/mp4, image/png",

There’s also this article: https://www.sitepoint.com/file-upload-form-express-dropzone-js/

1 Like

Thanks for your reply.
This seems to work:
acceptedFiles: image/png,.jpg,.mp4,.mov,.webm,

Can you tell me, now that I’ve made this change in dropzone.js, do I need to make the same change in dropzone.min.js?

Sorry, I’ve no idea.

That depends. is the minified version of the file created automatically when the human readable file changes?

You should never modify the actual library files. You should be passing in those values as options when you instantiate dropzone on the page. Hacking library files is big no no unless it absolutely can’t be avoided. If do have to hack the library file you should make note of the change so you and/or other developers know to reapply changes when updating the library to a newer version.

1 Like

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