I want to show the uploaded file below the fileUpload component after uploading the file. As default it just shows the file when i choose it but after i press upload button file name disappears. I checked all the attributes of the fileUpload tag but couldn't find anything related to it.
edit: Thanks Daniel, your solution works well, but you know the outputText is an external text under the fileUploader i would like to know if primeFaces has a solution to show the file when it is uploaded as it shows after choosing file like the picture below i want to see the file name also after uploading like this:
Just place a <h:outputText
and fill it with the file name from your bean after the and update it with your p:fileUpload
like this
<h:form prependId="false" enctype="multipart/form-data">
<p:fileUpload update="@form" mode="advanced" auto="true"
fileUploadListener="#{myBean.myFileUpload}"/>
<h:outputText value="#{myBean.myFileName}"/>
</h:form>
Inside your bean:
public void myFileUpload(FileUploadEvent event) {
myFileName = FilenameUtils.getName(event.getFile().getFileName());
}
Also take a look at the following BalusC answer: event.getFile().getFileName() is returning filename with complete path in JSF2.0 with PrimeFaces 3.5
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