Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
how to file upload browser window in only show .pdf file?
upload componets in browse file click and open browser window in only show .pdf file?
Hello,
I'm afraid that question is pretty much impossible to understand; are you asking "How to I limit the files presented by the Upload component to just be *.pdf?"
I'm afraid the simple answer is "you can't" - the vaadin Upload component is a wrapper around GWT File Upload, which in turn is really "just" an <input type="file"> element- and that, in turn, does not allow you to limit the files presented. See this stackoverflow question for a little more detail.
Sorry.
Charles.
Well it is of course possible to check the file-extension in a StartedListener:
public void uploadStarted(StartedEvent event) {
int dotIndex = event.getFilename().lastIndexOf('.');
String fileExt = event.getFilename().substring(dotIndex + 1);
String[] allowedFileTypes = configProvider.getAllowedFileTypes();
for(String allowedFileType : allowedFileTypes) {
if(StringUtils.equalsIgnoreCase(fileExt, allowedFileType)) {
validFiletype = true;
break;
}
}
if(!validFiletype) {
getView().interruptUpload();
}
}
Oh, absolutely, but you can't stop a user trying to pick the wrong type of tile in the first place...
Good shout though.
Cheers,
Charles.