Use the File Upload component to create a way for users
to upload a file to the server. This component consists of an input
field and an associated Browse button.
About this task
The user can manually specify the file in the input field
or can browse for a file by clicking
Browse.
To use a file upload component on a Faces JSP file:
Procedure
- Drag a File Upload component from the Faces Components
drawer on the palette to the Faces JSP file.
- In the Properties view for the File Upload component (fileupload),
enter the value (in the Value field) to which
you want to bind the file upload component. You can also click the
browse button to search for a value. The value can be a byte[], a
String (file content will be Base64 encoded) or a java.io.OutputString
object. The file upload component is usually bound to data storage,
such as a database or a JavaBean. When the page with the file upload
component is submitted, the content of the file is stored in the specified
location (a column in the database or a property of the bean).
- In the Validation panel of the Properties view:
- Check Value is required if you
want to require that the user specify a file.
- Specify in MIME notation the types of files that the
user can upload. Use MIME notation and separate file extensions with
commas (for example: text/html, image/gif).
- Specify the file types you do not want the user to upload.
Separate file extensions with commas (for example: xml, bat, exe).
- You can supply additional validation in the Value Changed
event in the Quick Edit view. Click the button next to Click
to create/edit custom validation code to switch to the
Quick Edit view.