Thanks to allowTypes, I only have a ban on downloading NOT files like "docx | xml | json". Is it possible to add somehow a mask, which in the dialog box will display only files of the type "docx | xml | json", and not all?

<p:fileUpload value="#{mainBean.uploadedFilesList}" allowTypes="/(\.|\/)(docx|xml|json)$/"/> 

    2 answers 2

    Yes you can. The fileUpload component in Primefaces has an accept attribute, in which you can specify the types of files that should be displayed in the file selection dialog. It should be remembered that:

    • The accept attribute is not processed in any way by the framework, but is merely a hint to the browser. The hint is accomplished by adding an accept attribute to the INPUT HTML element. It all depends on the native implementation in the browser, on how it handles this attribute.
    • The accept attribute accepts a type of parameters as an input that is different from the parameters of the attribute allowTypes , so simply copying from allowTypes to accept will not work. In order to find out which parameters to pass, you should be familiar with the specification of the HTML element INPUT. Briefly, a list of MIME types or predefined groups of MIME types is taken as input. You can start by reading this answer from SO
       <p:fileUpload value="#{mainBean.uploadedFilesList}" accept=".xml,.docx,.json"/>