Setting file extension using FileUpload

I am having trouble using the FileUpload.setAccept() to filter appropriately to a file extension of .pplx. I think the issue is that the .pplx is an unknown mimetype (its a o-calc xml file). The setAccept() works fine for known file type i.e. jpg, bmp, xml etc. However it will not show the .pplx files unless you switch to show all files.

I tried adding mime-mapping to the web.xml in tomcat, both is the root (conf directory) and the local web.xml (app and app-core) with no success. Am I missing something?

Thanks.

Hi,

Take a look at permittedExtensions property: https://doc.cuba-platform.com/manual-6.7/gui_FileUploadField.html#gui_FileUploadField_permittedExtensions

I’ve done this, and permittedextensions works in denying files that don’t match the extension, however it doesn’t filter the browse list, i.e. I see all files with all types of extensions besides the set .pplx

The setAccept() however is supposed to filter the browse dialog and it does only if its a known file type such as .xml. However setting it to .pplx it filters out everything leaving a blank browse, until I switch it back to all. I want to filter this list and I’m not sure why it only works on common file extensions.

If I set accept="*.pptx" then FileUploadField will use application/vnd.openxmlformats-officedocument.presentationml.presentation MIME type as expected. Firefox browser handles it correctly, but my Chromium does not.
Unfortunately, this behavior is not consistent across desktop/mobile browsers, even if you set correct MIME types. Accept attribute always have been just a hint for web browsers rather than normal filter functionality.