user1098178 user1098178 - 1 year ago 195
jQuery Question

dropzone.js image upload acceptedMimeTypes

I am using the dropzone.js plugin to add an image uploader to my application. I know this is probably a really basic question so apologies but what I want to do is limit the file extensions. This works for a single file extension,

<script type="text/javascript">
Dropzone.options.dropzone = {
accept: function(file, done) {
if (file.type != "image/jpeg") {
done("Error! Files of this type are not accepted");
else { done(); }

So my question is how to add multiple file extensions, i.e.


Answer Source

You could add more extensions to your if, like so:

if (file.type != "image/jpeg" && file.type != "image/png") {

This will check if the file type is different from ALL of the types you specify. For a file to pass the check, it has to be different from image/jpeg AND image/png


I would advise to look at enyo's answer since he is the author of Dropzone.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download