Uploading with a Form

Using JFile's FormName parameter, you can submit a form with your upload. We will script an upload with form elements. Using the parameter UseAppletInBrowser, we will embed the JFile UploadClient within the form.

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

JFile Applet with Form Fields

Exercise 6: Uploading with a Form

  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.

  3. Create a virtual directory called JFileScripts and map it to the physical JFileScripts you created in Step 2:

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

  5. Copy formresp.asp to the directory JFileScripts. 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.

  6. Create an HTML script containing the following lines. Name it formupload.htm and save it in the directory JFileScripts.
    <FORM name="JFileForm">
    <TABLE>
    <tr>
    	<td align="right">JFile Applet</td>
    	<td>
    	<APPLET codebase="/JFileScripts" code="softartisans.filetransfer.UploadClient.class" 
    	height="235" width="215" 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">
    	
    		<!-- When the parameter UseAppletInBrowser is set to 1, JFile will display the applet within the 
    		browser window, rather than in a pop-up window. -->
    		<PARAM name="UseAppletInBrowser" value="1">
    	
    		<!-- JFile will transfer the form assigned to the FormName parameter. -->
    		<PARAM name="FormName" value="JFileForm">
    	
    	</APPLET>
    	</td>
    </tr>
    
    <tr>
    	<td align="right">First Name</td>
    	<td align="left"><input type="text" name="firstname" size="10"></td>
    </tr>
    
    <tr>
    	<td align="right">Last Name</td>
    	<td align="left"><input type=vtext" name="lastname" size="10"></td>
    </tr>
    </TABLE>
    </FORM>
  7. To run the script, open the browser, and enter the URL http://localhost/jfilescripts/formupload.htm.

Understanding the Script




Previous Page Next Page