I am trying to display the each file in alert box before i implements my own logic as per my requirements. But its not working.
<h:head>
<script type="text/javascript">
function displayEachFile(file,callback){
alert(file);
}
</script>
</h:head>
<h:body>
<div class="card">
<h:form name="download">
<p:fileUpload value="#{fileBean.files}" mode="advanced" multiple="true" auto="true"
listener="#{fileBean.handleFileUpload}" widgetVar="hello" onAdd="displayEachFile"/>
</h:form>
</div>
</h:body>
</html>
Documentation Updated: https://primefaces.github.io/primefaces/11_0_0/#/components/fileupload
onAddhas 3 paramsthis, file, callback.Running example: pf-8657.zip
This gives you the opportunity to inspect the
fileand if you decide its OK to add you callcallback.For example:
You could do something like only add files named
primefaces.pdffor example.