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-pressed, application/x-rar, application/octet-stream,application/zip, pressed/rar,application/rar,application/x-pressed,multipart/x-zip,multipart/x-rar',
}
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-pressed, application/x-rar, application/octet-stream,application/zip, pressed/rar,application/rar,application/x-pressed,multipart/x-zip,multipart/x-rar',
}
Share
Improve this question
asked Jun 8, 2013 at 22:20
Subliminal HashSubliminal Hash
13.7k21 gold badges77 silver badges108 bronze badges
5
- What do you mean 'does not work'? Do you have an example of the error that occurs, or better yet, something to look at? – NT3RP Commented Jun 12, 2013 at 21:13
- Which browsers have you tested this with? Does it consistantly not work for .rar files across browsers or only in some (that support dropzone.js ofcourse). – Christian P. Commented Jun 19, 2013 at 13:17
- tested on latest chrome and firefox. Do not need IE. Yes I tried various rar files with no luck with all sorts of mime types I could find. – Subliminal Hash Commented Jun 19, 2013 at 13:52
-
I can see this behavior as well. I use
acceptedFiles: 'application/zip'
, and although it show only zip files in the file selection window, Dropzone doesn't send them. If I don't specify zip mime type, it does send zip files. – seldary Commented Aug 31, 2013 at 15:42 - Possible duplicate of File input 'accept' attribute - is it useful? – Mogsdad Commented Jan 8, 2016 at 3:12
2 Answers
Reset to default 3If 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.