简体   繁体   中英

dropzone.js - acceptedMimeTypes

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',
        }

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.

By default dropzone supports all mime types. if your requirement is not much specific just remove acceptedMimeTypes option. doing this will let you upload all kind of file extensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM