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. By default, JFile displays the system's native file selection dialog. To use JFile's file selector, set UseNativeFileSelection to 0.

File Selector Versions

JFile 2.1 includes a new version of the platform-neutral file selector that offers an improved user interface and several new features. For backward compatibility, the earlier version of the file selector is still available. To use the earlier version, see File Selector Version 1.

In JFile 2.1 and later versions, version 1 of the file selector is deprecated. It may become obsolete in a future version of JFile.

Text Customization

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.

Color Parameters

Use the file selector's color parameters to change the colors of background, button, file list box, and text. The color parameters allow you to modify the file selector's appearance to suit your application.

Sorting Files and Folders

The user may sort files and folders displayed in the file selection window by name, size, or last modified date. To sort the files and folders by one of these attributes, the user clicks one of three buttons at the top of the file/folder list text box. You may change the text displayed on these buttons by setting ButtonFileSorterText, ButtonSizeSorterText, and ButtonDateSorterText.

File Filters

Use the parameter FileFilterN to limit the file types that will be displayed in the file selector's extension field. The file filters are displayed in a drop-down list box. The listed filters include a filter name followed by a filter, for example, Web files(*.htm, *.asp).

Directory Uploads and Recursive Directory Uploads

The user can select files and/or directories to upload. JFile can upload a directory without its sub-directories, or recursively, that is, with its sub-directories, maintaining the original directory structure. To upload recursively, the user must check the upload type check box. To prevent recursive uploads you can hide the check box by setting HideRecursiveCheckBox to 1. See also, RecursiveCheckBoxOn.

Selecting Multiple Files

Using either the Shift or Ctrl key, the user can select several files to upload. To select more than one file within JFile's file selector, press Shift or Ctrl and, while the key is pressed, select the files.

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">
    	
    	<!-- 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="ButtonBackText" value="Previous Directory">
    	<param name="ButtonUpText" value="">
    	<param name="ButtonFileSorterText " value="Name">
    	<param name="ButtonSizeSorterText" value="File Size">
    	<param name="ButtonDateSorterText" value="Date last modified">
    	<param name="LabelUploadTypeSelectorText" value="Upload Type">
    	<param name="LabelExtenstionSelectorText" value="File Types">
    	<param name="ButtonCancelText" value="Quit">
    	<param name="ButtonDoneText" value="Apply">
    	
    	<!-- The FileFilter parameter allows you to list file 
    	type filters in the file type field.  The user can filter the file 
    	display by selecting a filter from the drop-down list.-->
    	<param name="FileFilter1" value="All files(*.*)">
    	<param name="FileFilter2" value="Web files(*.htm, *.asp)">
    	<param name="FileFilter3" value="Word Document(*.doc)">
    </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


Copyright © 2000-2003 SoftArtisans, Inc. All rights reserved.