danielm / uploader

A lightweight and very configurable jQuery plugin for file uploading using ajax(a sync); includes support for queues, progress tracking and drag and drop.
https://danielmg.org/demo/java-script/uploader
MIT License
1.17k stars 384 forks source link

what different about allowedTypes and extFilter? #52

Closed mh0625 closed 6 years ago

mh0625 commented 7 years ago

when I settings:

allowedTypes: 'image\/jpeg|bmp|jpg|png',
extFilter: 'jpg;png;bmp',

but the image of jpeg doesn't upload;

then I settings:

allowedTypes: 'image\/jpeg|bmp|jpg|png',
extFilter: 'jpg;png;bmp;jpeg',

the image of jpeg has upload;

then I remove extFilter settings, the image of jpeg also has upload.

so, I want to know, what different about allowedTypes and extFilter?

debasispanda commented 7 years ago

allowedTypes and extFilter are used for file validations when uploading.

allowedTypes : We can check type of file we are uploading. It may be an Image/PDF/Text etc. extFilter : Checks the extension of the file. We can allow files with specific extensions.

In your case you are passing both options, so you have to handle very care fully. When you pass both options, uploader will validate both file type as well as extension. If both matches then only you can upload.

allowedTypes: 'image\/jpeg|bmp|jpg|png',
extFilter: 'jpg;png;bmp',

In the above case it will check both file type and file extension. jpeg image should pass both the validation and for that you have to add .jpeg in the extFilter option as follows.

allowedTypes: 'image\/jpeg|bmp|jpg|png',
extFilter: 'jpg;png;bmp;jpeg',
danielm commented 6 years ago

Thanks for providing a very detailed response. Closing the issue for now.