I'm using <t:inputFileUpload>
from MyFaces to choose a file from a directory but, from the ManagedBean, when I try to get the full path of the file chosen, it returns null.
Look at the code:
InsereDocumento.xhtml
Choose a PDF file:
<br /> <t:inputFileUpload value="#{inserirBean.uploadedFile}" /> <br />
<h:commandButton value="inserir" action="#{inserirBean.submit}" />
inserirBean.java - I only put here the code that matters...
private UploadedFile uploadedFile;
public void submit() throws IOException {
String fullPath = FilenameUtils.getFullPath(uploadedFile.getName());
System.out.println("Full Path: " + fullPath);
}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
It prints anything, the FilenameUtils.getFullPath(uploadedFile.getName()) returns null
and the fullpath string variable is null
.
What's the problem here?