Topic: File Upload Plugin Not respecting accept type on mobile devices.
jcarvalho priority asked 6 months ago
When using MDB file upload plugin, " acceptedExtensions " are not working as expected on mobile devices.
1) When ".pdf" is provided as accepted extension, it is working as expected on browsers (where only pdf files are being allowed to selected to upload). But when opening the same site on mobile devices, it is allowing all the file types to be picked up.
2) Is there a way to provide general accepted file MIME types to [acceptedExtensions] input like application/pdf instead of .pdf as shown in your example docs.
Rafał Seifert free answered 6 months ago
export const mimeTypes: { mime_type: string; ext: string }[] = [
{ mime_type: 'application/x-abiword', ext: '.abw' },
{ mime_type: 'application/postscript', ext: '.ai' },
{ mime_type: 'application/x-freearc', ext: '.arc' },
{ mime_type: 'video/x-msvideo', ext: '.avi' },
{ mime_type: 'application/vnd.amazon.ebook', ext: '.azw' },
{ mime_type: 'application/octet-stream', ext: '.bin' },
{ mime_type: 'application/x-bzip', ext: '.bz' },
{ mime_type: 'application/x-bzip2', ext: '.bz2' },
{ mime_type: 'application/x-cdf', ext: '.cda' },
{ mime_type: 'application/x-csh', ext: '.csh' },
{ mime_type: 'application/msword', ext: '.doc' },
{
mime_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
ext: '.docx',
},
{ mime_type: 'application/vnd.ms-fontobject', ext: '.eot' },
{ mime_type: 'application/epub+zip', ext: '.epub' },
{ mime_type: 'application/gzip', ext: '.gz' },
{ mime_type: 'text/html', ext: '.htm' },
{ mime_type: 'image/vnd.microsoft.icon', ext: '.ico' },
{ mime_type: 'text/calendar', ext: '.ics' },
{ mime_type: 'application/java-archive', ext: '.jar' },
{ mime_type: 'text/javascript', ext: '.js' },
{ mime_type: 'application/json', ext: '.json' },
{ mime_type: 'application/ld+json', ext: '.jsonld' },
{ mime_type: 'audio/midi', ext: '.midi' },
{ mime_type: 'text/javascript', ext: '.mjs' },
{ mime_type: 'audio/mpeg', ext: '.mp3' },
{ mime_type: 'video/mp4', ext: '.mp4' },
{ mime_type: 'video/mpeg', ext: '.mpeg' },
{ mime_type: 'application/vnd.apple.installer+xml', ext: '.mpkg' },
{ mime_type: 'application/vnd.oasis.opendocument.presentation', ext: '.odp' },
{ mime_type: 'application/vnd.oasis.opendocument.spreadsheet', ext: '.ods' },
{ mime_type: 'application/vnd.oasis.opendocument.text', ext: '.odt' },
{ mime_type: 'audio/ogg', ext: '.oga' },
{ mime_type: 'video/ogg', ext: '.ogv' },
{ mime_type: 'application/ogg', ext: '.ogx' },
{ mime_type: 'audio/opus', ext: '.opus' },
{ mime_type: 'font/otf', ext: '.otf' },
{ mime_type: 'application/x-httpd-php', ext: '.php' },
{ mime_type: 'application/vnd.ms-powerpoint', ext: '.ppt' },
{
mime_type: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
ext: '.pptx',
},
{ mime_type: 'application/vnd.rar', ext: '.rar' },
{ mime_type: 'application/x-sh', ext: '.sh' },
{ mime_type: 'image/svg+xml', ext: '.svg' },
{ mime_type: 'application/x-shockwave-flash', ext: '.swf' },
{ mime_type: 'application/x-tar', ext: '.tar' },
{ mime_type: 'text/plain', ext: '.txt' },
{ mime_type: 'application/vnd.visio', ext: '.vsd' },
{ mime_type: 'audio/webm', ext: '.weba' },
{ mime_type: 'application/xhtml+xml', ext: '.xhtml' },
{ mime_type: 'application/vnd.ms-excel', ext: '.xls' },
{ mime_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ext: '.xlsx' },
{ mime_type: 'application/vnd.mozilla.xul+xml', ext: '.xul' },
{ mime_type: 'video/3gpp', ext: '.x3gp' },
{ mime_type: 'application/x-7z-compressed', ext: '.7z' },
];
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: MDB5 6.1.0
- Device: Mobile
- Browser: Chrome
- OS: Android
- Provided sample code: No
- Provided link: No
Rafał Seifert free commented 6 months ago
1) I've tested this case on a iPhone (brave browser) and it's working properly. What Android version and what browser are you using? We will have to recreate your specific environment to investigate the problem. 2) Unfortunately we don't allow users to provide these MIME types. We have them hard coded into our plugin. Do you have some specific MIME types that you are having problem with in our plugin?
jcarvalho priority commented 6 months ago
Thank you for the reply.
1) I tested it on my android today, It was allowing to upload the file irrespective of the format but then after upload it is showing a format error. I thought it would restrict files from the get go like how it did on the web where it freezes all the file types that are not the part of acceptedExtension input.
2) Could you please point out me to list of the hard coded MIME types that your plugin is using.
Rafał Seifert free commented 6 months ago
1) We will try to recreate and investigate this problem on Android 2) I've posted an answer below with our mimeTypes