To use the File Upload builder, you must enable file uploading.
# [ bowstreet.upload ]
# File Upload Settings
# This determines whether file upload is active for this server.
# This sets the directory where uploaded files will be stored upon successful upload.
# This determines the maximum file size that can be uploaded at one time in KiloBytes.
(If the file does not exist, create it.)
If you are using multiple File Upload builders on a page, the combined size of all files being uploaded from a single submit action must not exceed the limit specified in the Maximum File Size K field. Exceeding the upload limit causes the upload to fail.
Enable File Upload: Set the value of bowstreet.upload.enabled= to true.
Upload Destination Path: Set this property to the location in the WebSphere® Portlet Factory servlet file system where the uploaded file is temporarily stored.
Upload Maximum File Size (KB): This option puts a limit on how many kilobytes can be uploaded at a time (default 500 KB).
This step ensures that the new file upload enabled setting is deployed and upload is actually enabled before a file upload is attempted.
Note: If you use Microsoft Internet Explorer to upload a file that is more than the maximum file size specified, the Web browser interprets that as a Web page that cannot be found. As a result, you are shown the default error message for your application server when the browser cannot find a web page.
There is no graceful way to handle the event (for example, using an error handler method) in which a user tries to upload a file greater than the size allowed because the processing takes place within the browser, not in the WebSphere Portlet Factory servlet.
Locate the .../WEB-INF/config/cluster.properties file.
In this file locate the following section:
In the WEB-IFN/config/override.properties file, set the properties from that section in the following manner.
To have the changes in the override.properties file take effect, restart the application server or export the project again.
Optional: On the page that contains the File Upload control, you can include some text that explains what users can expect if they try to upload a file whose size is greater than the maximum file size property.
The location in the WAR (under WEB-INF/) to which files are uploaded by default is by necessity a temporary location.
Your application should treat it as such and move the files to the ultimate location after verifying they're appropriate to the application (right file extension(s), appropriate content, etc).
The location in the WAR doesn't make sense for long term storage for multiple reasons, including but possibly not limited to:
- the fact that the WAR on disk may be wiped out and replaced on a redeploy
- Use of a multinode cluster with multiple copies of the WAR on disk(s).
For security reasons, you should not enable file upload directly into the servable content area of the deployed application, to prevent malicious content from being uploaded into a location then downloadable from a browser.
The initial temporary upload location should be located below the WEB-INF folder of the deployed application, specifically for holding temporary uploaded files until the application has validated them and relocated them to a more permanent location.
Note: Because the WebContent/WEB-INF/config directory is by default an excluded resource, you need to override the team file and directory exclusion to ensure that your new or modified file is kept updated in source control storage.
Parent topic: File Upload builder: wpf7