rich:fileUpload is a component which provides files upload functionality and extends functionality of standard input with type=file.

Next example shows you File Upload which allows you to upload files to server. Files count allowed to upload managed with maxFilesQuantity attribute. Every uploaded file should be managed through fileUploadListener which called after every single file upload finished.

FileUpload example

This example allows to download up to 5 files. The file extension is limited to GIF, JPG, BMP, PNG and the maximum size of each file must not exceed 100kB

Details of Usage

File upload could works in automatic upload mode. You should just define immediateUpload upload attribute as true (false by default) and upload will be started just after file added to list. But you could freely manage the list (add or remove some files from list while upload performed)

In this example file types restricted to jpg, gif, png and bmp files using acceptedTypes attribute.

FileUpload uses two init parameters which should be defined in Filter definition in web.xml:

- createTempFiles boolean attribute which defines if the uploaded files will be stored in temporary files or available in listener just as byte[] data (false for this example).
- maxRequestSize attribute defines max size in bytes of the uploaded files (1000000 for this example).