How can I get the name of the file uploaded ?

UI Components for JSF
Post Reply
hilario_vs
Posts: 4
Joined: 25 Apr 2016, 09:08

16 May 2016, 21:17

@ManagedBean
public class FileUploadView {

private UploadedFile file;

public UploadedFile getFile() {
return file;
}

public void setFile(UploadedFile file) {
this.file = file;
}

public void upload() {
if(file != null) {
FacesMessage message = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
System.out.println(file.getFileName() + " is uploaded.");
}
}
}

lbroker
Posts: 30
Joined: 26 Jun 2014, 02:39
Location: Lithuania

16 May 2016, 21:21

Use file.getFileName()

smokeybandit
Posts: 277
Joined: 08 Jul 2013, 17:53

17 May 2016, 01:38

Your own pasted code tells you how to get the file name.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 58 guests