A Simple Upload


In the following exercise, we will script a simple, single-file upload. We will use the HTML <APPLET> tag to call JFile's UploadClient applet from an HTML script.

The exercise posts the upload to a server-side ASP (Active Server Pages) script that uses SoftArtisans FileUp to process the upload.

We will preset a single file - boot.ini - to upload. JFile allows the user to select additional files, delete files, enter a directory to upload, or delete a directory from the upload list.

To upload a directory, enter the directory name in the File/Dir input field. To upload a directory recursively (that is, with its subdirectories), check Recursive. For detailed instructions on uploading a directory, see, Uploading a Directory.
The UploadClient Applet

Exercise: A Simple Upload

  1. 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.

  2. 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).

  3. 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."

  4. Create an HTML script containing the following lines. Name the script upload.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">
    		
    </APPLET>
  5. To run the script, open the browser, and enter the URL http://localhost/jfilescripts/upload.htm.

Understanding the Script


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