Javascript – dropzone.js – acceptedMimeTypes

dropzone.jsjavascriptjquerymimemime-types

I am trying to implement some limitation to the file types allowed for upload using dropzone.js. Somehow the below code works for Word, Excel and Powerpoint documents but it doesn't work for .zip and .rar. Any suggestions?

   Dropzone.options.filedrop = {
        maxFilesize: 4096,
        acceptedMimeTypes: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/excel,application/vnd.ms-excel,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.presentationml.slideshow, application/x-rar-compressed, application/x-rar, application/octet-stream,application/zip, compressed/rar,application/rar,application/x-compressed,multipart/x-zip,multipart/x-rar',
        }

Best Solution

If this question (and its answers) are any indication, you may be able to avoid explicitly listing the mime-type in favour of simple .extension style.

From what I have examined in the dropzone.js source code, all that the library does it check that the mimetypes are valid, and then assign them as the accept attribute on the file input element.

Related Question