The File Selector

When a user click's the upload applet's "Add Files/Directory" button, a file selection window will open. JFile allows you to display either the system's native file selection dialog, or JFile's platform-neutral file selector.

JFile's file selector includes several text parameters that enable customization of all of the text displayed in the selection window. This allows you to change the language displayed in the file selector.

By default, JFile displays the system's native file selection dialog. To use JFile's file selector, set UseNativeFileSelection to 0.

Use JFile's file selector parameters to customize the file selection window.

File Selector Parameters
JFile's File Selector

Exercise 10: A Simple Upload

  1. If you created the physical and virtual JFileScripts directories in a previous lesson, go to Step 4. If you did not create the directories, go to Step 2.

  2. Create a directory called JFileScripts and copy the file formresp.asp to this directory. Formresp.asp is a server-side upload processing script that you will find in JFile's Samples\Upload\Simple directory (installed by default at C:\Program Files\SoftArtisans\JFile). Formresp.asp uses SoftArtisans FileUp to process the upload.

  3. Copy filetransfer.jar (for Netscape) and/or filetransfer.cab (for Internet Explorer) to the directory JFileScripts. These files are in JFile's installation directory (by default, C:\Program Files\SoftArtisans\JFile).

  4. Create a virtual directory called JFileScripts and map it to the physical JFileScripts you created in step 1:

    1. Open the Internet Information Services (IIS) explorer.
    2. Right-click Default Web Site.
    3. Select New -> Virtual Directory.
    4. For Alias, enter JFileScripts.
    5. Browse to the JFileScripts directory you created in step 1.
    6. Check "Read" and "Run scripts."
    7. Click "Finish."

  5. Create an HTML script containing the following lines. Name the script upload_fileselector.htm and save it in your JFileScripts directory.
    <APPLET codebase="/JFileScripts" code="softartisans.filetransfer.UploadClient.class" 
    height="0" width="0" mayscript archive="filetransfer.jar" name="fileupload">
    	
    	<!-- The Cabbase parameter specifies the cab file containing the applet. -->
    	<PARAM name="cabbase" value="filetransfer.cab">
    
    	<!-- The PostURL parameter specifies the URL to which the file will be posted. -->
    	<PARAM name="PostURL" value="http://localhost/jfilescripts/formresp.asp">
    	
    	<!-- The FileName# parameter specifies a file to transfer.  When uploading more than one file, use 
    	"FileName1," "FileName2," etc. -->
    	<PARAM name="FileName1" value="c:\boot.ini">
    	
    	<!-- Setting UseNativeFileSelection to 0 enables JFile's file selector. -->
    	<param name="UseNativeFileSelection" value="0">
    
    	<!-- The file selector text parameters allow you to change all of the 
    	text displayed in the file selection window. -->
    	<param name="CustomFileSelectorTitleText" value="Select files/folders to upload">
    	<param name="LabelLookInText" value="Search">
    	<param name="ButtonChangeDirText" value="Apply">
    	<param name="LabelUploadTypeSelectorText" value="Upload Type">
    	<param name="ChoicesFilesOnlyText" value="File">
    	<param name="ChoiceFilesAndDirsText" value="File and directory">
    	<param name="ChoiceFilesAndDirsRecText" value="File and recursive directory">
    	<param name="LabelExtenstionSelectorText" value="File Types">
    	<param name="LabelAdditionalFilterText" value="Filter">
    	<param name="ButtonRefilterText" value="Apply">
    	<param name="ButtonCancelText" value="Quit">
    	<param name="ButtonDoneText" value="Apply">
    		
    </APPLET>
  6. To run the script, open the browser, and enter the URL http://localhost/jfilescripts/upload_fileselector.htm.

  7. Click "Add Files/Directory" to open the file selector.

Understanding the Script




Previous Page Next Page