<rich:fileUpload fileUploadListener="# {bean.fileUploadAction}"
immediateUpload="true" acceptedTypes="xls" maxFilesQuantity="1">
</rich:fileUpload>
in rich file uplaod i given acceptedTypes="xls" ,but on "add" in the file select box Files of types is showing all. I want to restrict it to only some specific format how can i do that. Any kind of help is appriciated,thanks in advance..
That's only possible if it generates the following HTML (and the page is opened by a HTML5 compatible webbrowser):
However, it doesn't do that. Instead, it generates a simple HTML4 compatible
<input type="file">
without theaccept
attribute and does a file extension check on the selected file by JavaScript.So you're out of luck here. You'd basically need to replace the
<rich:fileUpload>
by another component which generates exactly the desired HTML with the properaccept
attribute set on<input type="file">
. As far as I see now, no one JSF component library offers such a component yet. You might need to homegrow it.See also:
accept
attribute oftype=file
This alternative way may solve your problem to some extent. Add an
onclick
event to your<rich:fileUpload
components as below.