2

I need to upload multiple files, but I need to upload them all together then the "submit" button is clicked (that either ALL files are stored, or nothing).

How can I achieve this? And how can I get a list of files which I uploaded?

here is my code:

<h:form>
    <p:fileUpload fileUploadListener="#{bean.moveFile}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"  mode="advanced" dragDropSupport="true" multiple="true"  />  
    <h:commandButton value="Speichern" action="#{bean.submit}" />
</h:form> 
Lisa
  • 4,333
  • 2
  • 27
  • 34
Niko
  • 1,054
  • 5
  • 25
  • 52

1 Answers1

1

Check out the Primefaces Showcase. The handleFileUpload method gets called for every uploaded file. If you want to have a list of uploaded files, just store them in an adequate data structure.

If you need to know how to store a specific uploaded file, read these articles:

1.) j2ee primefaces fileupload file saving destination

2.) How to Upload a file using JSF/Primefaces?

3.) Where does p:fileUpload save my file?

Community
  • 1
  • 1
Manuel
  • 3,828
  • 6
  • 33
  • 48
  • So do I need to create my own custom list to view all already uploaded files? what happens to the uploaded files, when the windows is closed? are they deleted? – Niko Nov 21 '13 at 20:44
  • 1
    Yes. If you dont store the files within the `moveFile` method, the files won't be stored. I think they are just a temporary object and live as long until the request is processed. SO, store your files to the harddrive, database or somewhere else before they are lost. – Manuel Nov 21 '13 at 22:16