Minimizing User Interaction

Use of the FileUpload applet will cause various dialogs and prompts to be displayed to the user. The topics below describe how these different user interactions can be minimized:

Applet Security Dialog
Upload Confirmation Dialog
Preselecting the Browse Directory
Preselecting Files


Applet Security Dialog

Because the Upload Applet requires access to the user's local hard drive, the first thing it does is request the permissions needed. This causes the web browser to display its security dialog asking the user to grant the requested permissions. This prompting is forced by the web browser as part of its security and will happen each time the applet is loaded, typically once per browser session. The only way to prevent this dialog from displaying in future browser sessions is for the user to check the 'Always trust content from...' box under Internet Explorer or the 'Remember this decision' box under Netscape Navigator.


Upload Confirmation Dialog

To prevent files from automatically being uploaded from a user's hard disk without their approval, the Upload Applet will always prompt the user for confirmation and display the list of files being uploaded. To help avoid this dialog set the noConfirm parameter to true. As long as you do not attempt to preselect any files for the user, the dialog will be skipped.  If you do preselect any files, the dialog will still be displayed. However, the user will have the option to skip the dialog in the future by checking the "Don't ask for confirmation" box.


Preselecting the Browse Directory

If the user must select the files to be uploaded, you can save them from having to navigate to the directory where their files are located by setting the directory parameter. The easiest way to do this is to save the contents of the FILE_DIR parameter passed to your upload script and using that value to set the directory parameter the next time. Refer to to the Basic Upload sample application for an example of this technique.


Preselecting Files

If you know ahead of time which files will be uploaded you can use one or more fileN parameters to preselect them and automatically submit the form. Below is an example:

<BODY onLoad="document.FileUpload.submit(document,document.forms[0],true)">
<FORM ACTION="upload.asp">
</FORM>
<APPLET CODE=FileUpload.class ARCHIVE=FileUpload.jar NAME=FileUpload 
        CODEBASE="/AppletFile/classes" WIDTH=420 HEIGHT=180 MAYSCRIPT>
<PARAM NAME="cabbase" VALUE="/AppletFile/classes/FileUploadIE3.cab">
<PARAM NAME="cabinets" VALUE="/AppletFile/classes/FileUpload.cab">
<PARAM NAME="file1" VALUE="C:\status\june.xls">
<PARAM NAME="file2" VALUE="C:\status\june.doc">
</APPLET>

In this example, the Applet parameters file1 and file2 are used to preselect a spreadsheet and word processing document from known locations on the user's hard drive. To automatically submit the upload, the onLoad attribute of the BODY tag calls the FileUpload.submit method passing it the form to be uploaded.

You can also use the addFile and addFiles methods to preselect files using client-side JavaScript.