Use File Upload components
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.
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:
- 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 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.
To learn more about using the File Upload component, do the following tutorial (especially the exercise on using the file upload component):
Tutorial: Displaying dynamic information on Web pages with JavaServer Faces
Related concepts
JavaServer Faces
Related tasks
Creating Faces applications - overview
Creating a Faces JSP file
Adding validation to Faces input components
Related reference
Faces components reference
Attributes for Faces components