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

The next example shows you File Upload which allows you to upload files to the server. Files number allowed to upload is managed with maxFilesQuantity attribute. Every uploaded file should be managed with fileUploadListener which is called after every single file upload is 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 a file added to the list. But you could easily manage the list by adding or removing some files from the list during the upload.

Also starting from 3.2.2 version File Upload could be configured to use flash object in order to provide additional features (covered in developer guide) to component.

In this example file types are restricted to jpg, gif, png and bmp files with the help of acceptedTypes attribute.

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

- createTempFiles boolean attribute which defines whether the uploaded files are 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).