I'm a primefaces n00b and I'm having an issue with the fileUpload component. I'm attempting to restrict the file type of the uploaded file to .pdf files exclusively, however the component is allowing the upload of any file I select. From my understanding of the documentation and online examples I should be able to filter the file selection by type using the allowTypes attribute of the fileUpload tag. My tag is as follows:
Code: Select all
<p:fileUpload fileUploadListener="#{pressMain.handleFileUpload}"
allowTypes="*.pdf" sizeLimit="4194304" auto="TRUE"
width="49" height="49" image="/resources/images/browse2.JPG"/>
Code: Select all
public void handleFileUpload(FileUploadEvent event)
{
upload = event.getFile();
if( upload != null )
{
FacesMessage msg = new FacesMessage("Succesful", upload.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
Any advice you can give me about what I'm doing wrong would be useful. If you need any more info, just ask.