In the following exercise, we will script a simple, single-file download. We will use the HTML
<APPLET> tag to call JFile's
DownloadClient
applet from an HTML script. The script below gets the file sample.doc from a specified directory on the server, saves it in the user's Temp directory, and displays a download confirmation page. We will preset one file to download, using the FileNameN parameter. To add files to the download list, use "FileName2," "FileName3," etc. The user may rename a file in the download list, remove a file from the list, or remove all files from the list. |
|
<APPLET codebase="/JFileScripts" code="softartisans.filetransfer.DownloadClient.class" height="0" width="0" mayscript archive="filetransfer.jar" name="filedownload"> <!-- The Cabbase parameter specifies the cab file containing the download applet. --> <PARAM name="cabbase" value="filetransfer.cab"> <!-- The FinalURL parameter specifies the URL to display when the download is complete. --> <PARAM name="FinalURL" value="http://localhost/jfilescripts/confirm.asp"> <!-- The FileName# parameter specifies the local path to which to download the file, and the downloaded file's name on the local machine. When downloading more than one file, use "FileName1," "FileName2," etc. --> <PARAM name="FileName1" value="c:\temp\sample.doc"> <!-- The URL# parameter specifies the URL of the file to download from the server. When downloading more than one file, use "URL1," "URL2," etc.--> <PARAM name="URL1" value="http://localhost/jfilescripts/sample.doc"> </APPLET>
<PARAM name="UseAppletInBrowser" value=1>If you do not set UseAppletInBrowser to 1, that is, if you display the applet in a separate window, set Height and Width to 0.
![]() |
To prevent the user from renaming a file on the download list, set the parameter NoRename
to 1: <PARAM name="NoRename" value="1"> To prevent the user from removing files from the download list, set the parameter NoRemove to 1: <PARAM name="NoRemove" value="1"> |