I'm using the primefaces fileUpload component and then I inspect the FileUploadEvent.getFile but I don't see a way to reliably get the extension. Any ideas?
getFile() returns an org.primefaces.model.UploadedFile object which has a method getFileName to return the file name. Then you can get the extension from the filename.
UploadedFile tfile = event.getFile();
String str = tfile.getFileName();
String ext = str.substring(str.lastIndexOf('.'), str.length());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With