user1098178 user1098178 - 5 months ago 82
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.



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.