Upload Applet

The Upload Applet is a major improvement over the <INPUT TYPE="FILE"> form element used for performing RFC 1867 based file uploads. By using this applet with your form, you can help automate the task of selecting files while providing better control and feedback during the upload process.

Tag Syntax

<APPLET CODE=FileUpload.class ARCHIVE=FileUpload.jar NAME=FileUpload 
        CODEBASE="/AppletFile/classes" WIDTH=420 HEIGHT=180 MAYSCRIPT>
    <PARAM NAME="cabbase" VALUE="/AppletFile/classes/FileUploadIE3.cab">
    <PARAM NAME="cabinets" VALUE="/AppletFile/classes/FileUpload.cab">
      :
     Optional Parameters
      :
</APPLET>
<FORM ACTION="upload script" onSubmit="return document.FileUpload.submit(document,this,true)">
     :
     Optional Input Elements
     :
</FORM>

Parameters

alternateUrl, authorization, autoZip, bgColor, browseTitle, cabbase, cabinets, directory, errorLimit, fileListTitle, fileN, fileMask, filterN, finishUrl, iconN, includeDate, includeMD5, language, maxFiles, minFiles, noAdd, noConfirm, noFileList, noProgress, noRemove, selectFolders, timeOut, warningLimit

Methods

addFile, addFiles, clearFiles, getAutoZip, getBrowseTitle, getDirectory, getFile, getFileCount, getFileDate, getFileMask, getFileSizegetIncludeDate, getIncludeMD5, getUploadProgress, getUploadStatus, hasChanged, hasInitialized, removeFile, select, selectAdd, selectRemove, setAutoZip, setBrowseTitle, setDirectory, setFileMask, setIncludeDate, setIncludeMD5, submit


Parameters

The Upload Applet can be customized at initialization time by adding additional <param name="paramname" value="paramvalue"> tags inside the <applet> tag.

alternateUrl

<param name="alternateUrl" value="URL">

URL to an alternate HTML form to display if Applet lacks permissions needed for file upload processing.

Default: none
Notes:
This parameter can be used to provide an alternate HTML page that will automatically be displayed in the case where the user does not agree to grant permissions to the Applet or the browser that is being used does not support digitally signed Applets. This alternate HTML page could be simply informational or contain a version of the upload form that only uses <INPUT TYPE=FILE> tags for uploading files.
Example: Display alt.html if permissions are not granted

<PARAM NAME="alternateUrl" VALUE="alt.html">

authorization

<param name="authorization" value="credentials">

Parameter for passing authorization information to the Applet.

Default: none
Notes: When setting the useSockets parameter to true, the parameter must be specified if the upload script is protected by Basic Authentication. To allow authentication to work correctly, your server-side script should set the value of this parameter to the CGI variable HTTP_AUTHORIZATION. Otherwise, an access denied error will occur. See the Basic Upload sample application for a complete example.

Example: Set the parameter from an Active Server Pages script

<PARAM NAME="authorization" VALUE="<%=Request.ServerVariables("HTTP_AUTHORIZATION")%>">

autoZip

<param name="autoZip" value="{true|false}">

Automatically zip files into a single archive for uploading.

Default: false
Notes: This parameter is useful for improving upload performance by compressing the data that needs to be transferred.
Example: Turn compression on.

<PARAM NAME="autoZip" VALUE="true">

bgColor

<param name="bgColor" value="#RRGGBB">

Background color of File List when displayed within the HTML page.

Default: undefined
Notes:
Setting the value of this parameter to match the BGCOLOR attribute of the <BODY> tag in your HTML page, will allow the File List to blend with the rest of your form. Setting this value is also useful it you are hiding the applet since it is not possible to set the height and width to zero. The value must be the pound sign (#) followed by six hexadecimal digits representing red, green, and blue color values. Color names are not supported. If this parameter is not specified, the default is browser and operating system dependent.
Example: Set background color to yellow

<PARAM NAME="bgColor" VALUE="#ffff00">

browseTitle

<param name="browseTitle" value="text">

Title displayed in the Browse dialog.

Default: "Select files to upload"
Notes:
This parameter is useful for giving users a better idea of what type of file you want them to select.
Example: Ask user for their timecard

<PARAM NAME="browseTitle" VALUE="Select your timecard file">

cabbase

<param name="cabbase" value="URL">

Location of cabinet file containing the Applet.

Default: none
Notes:
This required parameter is an URL used to locate the cabinet file containing the IE 3.02 version of the Applet. The value of this URL will depend on where AppletFile is installed but should ultimately point to the cabinet file FileUploadIE3.cab.
Example: Set the location of cabinet file to be under the applets folder

<PARAM NAME="cabbase" VALUE="/applets/FileUploadIE3.cab">

cabinets

<param name="cabinets" value="URL">

Location of cabinet file containing the Applet.

Default: none
Notes:
This required parameter is an URL used to locate the cabinet file containing the IE 4.0 and higher version of the Applet. The value of this URL will depend on where AppletFile is installed but should ultimately point to the cabinet file FileUpload.cab.
Example: Set the location of cabinet file to be under the applets folder

<PARAM NAME="cabinets" VALUE="/applets/FileUpload.cab">

directory

<param name="directory" value="path">

Start Browse dialog in the directory path.

Default: root directory
Notes:
Setting this parameter to a path on the client's system will save the user from having to navigate to the directory containing the files to be uploaded. If this parameter is omitted or is set to a non-existant directory, the root directory will be used.
Example: Start Browse dialog in C:\My Documents

<PARAM NAME="directory" VALUE="C:\My Documents">

errorLimit

<param name="errorLimit" value="bytes">

Limit the size of a file that can be uploaded to maximum number of bytes.

Default: 0 (unlimited)
Notes:
If you want to prevent clients from attempting to upload large files, you can set the parameter to the maximum size permitted for a single file. If a file larger than this value is selected for upload, an error message will be displayed when the form is submitted. To display a warning message instead, use the warningLimit parameter.
Example: Display an error message if file is larger than 1,000,000 bytes

<PARAM NAME="errorLimit" VALUE="1000000">

fileListTitle

<param name="fileListTitle" value="text">

Title displayed in the File List dialog.

Default: "Select files to be uploaded"
Notes:
If you use the select method to display the File List as a dialog, this parameter can be used to customize the title for that dialog giving users a better idea of what type of files you want them to select.
Example: Ask user for their email attachments

<PARAM NAME="fileListTitle" VALUE="Email attachments">

fileN

<param name="fileN" value="path">

Provide a list of preselected files for upload.

Default: none
Notes: One or more fileN parameters can be used to preselect the files to be uploaded. Each parameter value must represent an absolute path to an existing file on the client system. These files will automatically appear in the File List dialog.
Example: Preselect three files for upload

<PARAM NAME="file1" VALUE="C:\transfer\a.dat">
<PARAM NAME="file2" VALUE="C:\transfer\b.dat">
<PARAM NAME="file3" VALUE="C:\transfer\c.dat">

fileMask

<param name="fileMask" value="pattern">

Display files in the Browse dialog that match the file mask.

Default: none
Notes: This parameter is used to control which files are displayed in the Browse dialog. The pattern can start or end with the asterisk ('*') wild card character to match files ending or starting with the rest of the pattern.
Example: Display only ZIP files in the Browse dialog

<PARAM NAME="fileMask" VALUE="*.zip">

filterN

<param name="filterN" value="path">

Define a file type filter for the Browse dialog.

Default: "All Files (*.*)"
Notes: One or more filterN parameters can be used to define file type filters for the Browse dialog. The format of a filterN parameter is a textual description followed by a comma separated list of file masks enclosed in parenthesis. When the Browse dialog is first opened, the file masks defined by filter1 will be used to filter the files being displayed unless a fileMask parameter is specified.
Example: Define three filters

<PARAM NAME="filter1" VALUE="HTML Files (*.htm,*.html,*.asp)">
<PARAM NAME="filter2" VALUE="Graphic Files (*.jpg,*.jpeg,*.gif)">
<PARAM NAME="filter3" VALUE="All Files (*.*)">

finishUrl

<param name="finishUrl" value="URL">

URL of the document to display upon completion of uploading.

Default: By default, the response from the upload script is displayed in the browser window.
Notes: After all of the files have been uploaded, the URL specified by this parameter will be requested and displayed. The query string parameter STATUS will be included on the URL to containing the response of the upload script. The possible values for STATUS are application defined but must be no larger than 40 characters.
Example: Run the clean up script after the upload is finished.

<PARAM NAME="finishUrl" VALUE="cleanup.asp">

iconN

<param name="iconN" value="iconspec">

Define a file icon for the Browse dialog.

Default: None
Notes: One or more iconN parameters can be used to define file icons for the Browse dialog. The format of a iconN parameter is an URL to an image file followed by a comma separated list of file extensions. When the Browse dialog displays a file, it will lookup the appropriate file icon using that file's extension.
Example: Define three icons

<PARAM NAME="icon1" VALUE="html.gif (htm,html)">
<PARAM NAME="icon2" VALUE="graphic.gif (jpg,jpeg,gif,bmp,tif,tiff)">
<PARAM NAME="icon3" VALUE="text.gif (txt,text,log)">

includeDate

<param name="includeDate" value="{true|false}">

Include the last modified date of each uploaded file.

Default: false
Notes: This parameter is useful for applications that need to track when a file was last modified. By setting this parameter, each FILEn parameter in the upload stream will have a corresponding DATEn parameter. Also note that this parameter is ignored if autoZip is set because last modified date information is automatically included as part of the ZIP archive format.
Example: Include last modified dates.

<PARAM NAME="includeDate" VALUE="true">

includeMD5

<param name="includeMD5" value="{true|false}">

Include an MD5 checksum for each uploaded file.

Default: false
Notes: This parameter is useful for validating that the data in each file was not corrupted during transfer. By setting this parameter, each FILEn parameter in the upload stream will have a corresponding MD5_n parameter. By recalculating the MD5 checksum on the server, your application can compare it with the uploaded value to validate the integrity of the uploaded file. Also note that this parameter is ignored if autoZip is set because checksum information is automatically included as part of the ZIP archive format.
Example: Include MD5 checksums.

<PARAM NAME="includeMD5" VALUE="true">

language

<param name="language" value="language code">

Language to use for text of messages.

Default: en (English)
Notes: This parameter represents the ISO language code specifying the language to use for the text of various dialog boxes and messages. Currently only en (English), de (German) and fr (French) are supported. If an unsupported language code is specified, English will be used.
Example: Enable German language messages

<PARAM NAME="language" VALUE="de">

maxFiles

<param name="maxFiles" value="count">

Maximum number of files to select for upload.

Default: 1
Notes: This parameter is useful for restricting the number of files that can be uploaded. An unlimited number of files can be uploaded by setting this parameter to zero.
Example: Make sure user uploads no more than two files at a time

<PARAM NAME="maxFiles" VALUE="2">

minFiles

<param name="minFiles" value="count">

Minimum number of files to select for upload.

Default: 1
Notes: This parameter is useful for making sure that all of the required files have been selected. The value of this parameter must be less than or equal to the maxFiles parameter.
Example: Make sure user selects at least two files for upload

<PARAM NAME="minFiles" VALUE="2">

noAdd

<param name="noAdd" value="{true|false}">

Do not provide an Add button in the File List dialog.

Default: false
Notes: This parameter is useful for restricting File List operations. By setting this parameter to true, you can prevent users from adding additional files to the File List. This parameter is also useful for implementing your own Add button. See the selectAdd method for details.
Example: Hide the 'Add' button

<PARAM NAME="noAdd" VALUE="true">

noConfirm

<param name="noConfirm" value="{true|false}">

Suppress the file upload confirmation dialog.

Default: false
Notes: Setting this parameter to true is useful if you do not want the user to be prompted with the list of files to be uploaded. If the addFile method or any fileN parameters are used to preselect files, the user will still be prompted. However, the form will have a "Don't ask me next time" checkbox to suppress the dialog during subsequent uploads.
Example: Supress confirmation dialog

<PARAM NAME="noConfirm VALUE="true">

noFileList

<param name="noFileList" value="{true|false}">

Do not display the File List dialog within the HTML page.

Default: false
Notes: This parameter is useful for customizing the Applet's user interface. If you want to display the File List dialog in a separate window whenever a button is pressed, set this parameter to true and call the select method from the button's onClick event.
Example: Hide the File List dialog

<PARAM NAME="noFileList" VALUE="true">

noProgress

<param name="noProgress" value="{true|false}">

Do not display the Progress dialog during the upload.

Default: false
Notes: This parameter is useful for customizing the Applet's user interface. If you want to create your own progress dialog in JavaScript, set this parameter to true and call the getUploadProgress and getUploadStatus methods to update your display.
Example: Hide the Progress dialog

<PARAM NAME="noProgress" VALUE="true">

noRemove

<param name="noRemove" value="{true|false}">

Do not provide a Remove button in the File List dialog.

Default: false
Notes: This parameter is useful for restricting File List operations. By setting this parameter to true, you can prevent users from removing files from the File List. This parameter is also useful for implementing your own Remove button. See the selectRemove method for details.
Example: Hide the 'Remove' button

<PARAM NAME="noRemove" VALUE="true">

selectFolders

<param name="selectFolders" value="{true|false}">

Allow folders to be selected for upload in the Browse dialog.

Default: false
Notes: When this parameter is set to true, the Browse dialog allows the user to select folders for upload. This will cause all the files in the selected folder that match the current file mask or filter to be added to the File List.
Example: Enable folder selection

<PARAM NAME="selectFolders" VALUE="true">

timeOut

<param name="timeOut" value="seconds">

The length of time in seconds to wait for a response from the server while uploading.

Default: 100
Notes: When AppletFile encounters networking errors while processing an upload, it will attempt to retry. Using this parameter, you can control how long AppletFile should continue to try to communicate with the server before giving up.
Example: Set the timeout value to 300 seconds

<PARAM NAME="timeOut" VALUE="300">

warningLimit

<param name="warningLimit" value="bytes">

Issue a warning if the size of a file to be uploaded is greater than this number of bytes.

Default: 0 (unlimited)
Notes:
This parameter can be set to warn clients attempting to upload large files. If a file larger than this value is selected for upload, a warning message will be displayed when the form is submitted. To prevent the file from being uploaded, use the errorLimit parameter.
Example: Display a warning message if user attempts to upload a file larger than 200,000 bytes

<PARAM NAME="warningLimit" VALUE="200000">

Methods

The Upload Applet is fully scriptable using the methods found below. You can use these methods to implement your own JavaScript-based user interface and validation logic.

addFile

addFile(path)

Adds a file to the File List dialog.

Parameter Description
path Absolute path of the file to be added.

Returns: Boolean indicating if the file was added successfully.
Notes: Similar to the fileN parameter, this method can also be used to preselect files. If the file does not exist, it will not be added to the file list and the function will return false.
Example: The following JavaScript code will add files based on a numbering scheme:

for (i = 0; i < 1000; i++)
    document.FileUpload.addFile("C:\stage\file" + i + ".dat");

addFiles

addFiles(path, mask, traverse)

Adds files to the File List dialog.

Parameter Description
path Absolute path of the directory containing the files to be added.
mask File mask used to match the files to be added. "*.*" matches all files.
traverse Boolean flag that controls the traversal of subdirectories. True will add files from subdirectories.

Returns: Integer indicating the number of files that were added.
Notes: Similar to the addFile method, this method can also be used to preselect files. This method is particularly useful for preselecting an entire directory of files.
Example: The following JavaScript code will add all of the GIF files in a directory tree:

document.FileUpload.addFiles("C:\My Documents", "*.gif", true);

clearFiles

clearFiles()

Clears all of the files from the File List dialog.

Returns: Nothing.
Notes: This method is useful for emptying out the File List prior to adding files using the addFile method. It can also be used to implement your own custom "Remove All" button.
Example: The following tag will add a 'Reset' button to a form that will remove selected files when pressed.

<INPUT TYPE="button" VALUE="Reset" onClick="document.FileUpload.clearFiles()">

getAutoZip

getAutoZip()

Returns a flag indicating if files will be zipped during upload.

Returns: Boolean flag.
Notes: This method will return the current setting of the AutoZip flag as specified by the last call to setAutoZip or the setting of the autoZip parameter.
Example: The following JavaScript code will check to see if AutoZip is turned on:

if (document.FileUpload.getAutoZip())
    alert('AutoZip is on');
else
    alert('AutoZip is off');

getBrowseTitle

getBrowseTitle()

Returns the current title of the Browse dialog.

Returns: String containing the dialog title.
Notes: This method will return the current title of the Browse dialog. This title can be set by either the browseTitle parameter or the setBrowseTitle method.
Example: The following JavaScript code will display the dialog title:

alert('The current title is: ' + document.FileUpload.getBrowseTitle());

getDirectory

getDirectory()

Returns the current directory of the Browse dialog.

Returns: String containing the directory path.
Notes: This method will return the current directory of the Browse dialog. This directory can be set by the directory parameter, the setDirectory method, or by the user navigating to a directory and selecting a file using the Browse dialog.
Example: The following JavaScript code will display the current directory:

alert('The current directory is: ' + document.FileUpload.getDirectory());

getFile

getFile(index)

Returns a file from the File List dialog.

Parameter Description
index Number specifying the position (starting at 1) of the file

Returns: String containing the file path.
Notes: This method will return the path of a file from the File List dialog. Using this method along with getFileCount you can enumerate the files selected for upload and perform your own customized display and validation.
Example: The following JavaScript code will enumerate the files in the File List dialog:

count = document.FileUpload.getFileCount();
for (i=1; i <= count; i++)
    alert(document.FileUpload.getFile(i));

getFileCount

getFileCount()

Returns the number of files in the File List dialog.

Returns: Number representing the number of files selected for upload.
Notes: This method will return the number of files currently in the File List dialog. Using this method along with getFile, getFileDate, and getFileSize you can enumerate the files selected for upload and perform your own customized display and validation.
Example: The following JavaScript code will display the number of files in the File List dialog:

alert('There are ' + document.FileUpload.getFileCount() + 
      ' files selected for upload.');

getFileDate

getFileDate(index)

Returns the last modified date of a file in the File List dialog.

Parameter Description
index Number specifying the position (starting at 1) of the file

Returns: Date when the file was last modified.
Notes: This method will return the last modifed date of a file from the File List dialog. Using this method you can perform your own customized display and validation.
Example: The following JavaScript function will check to see if a file has been modifed since a specific date:

function modifiedSince(index, originalDate)
{
    var lastModified = document.FileUpload.getFileDate(index);
    if (lastModified > originalDate)
        alert('File has been recently modified!');
}

getFileMask

getFileMask()

Returns the file mask to use for the Browse dialog.

Returns: String containing the file mask.
Notes: This method will return the file mask. This mask can be set by either the fileMask parameter or the setFileMask method.
Example: The following JavaScript code will display the current file mask:

alert('The current file mask is: ' + document.FileUpload.getFileMask());

getFileSize

getFileSize(index)

Returns the size in bytes of a file in the File List dialog.

Parameter Description
index Number specifying the position (starting at 1) of the file

Returns: Number containing the file's size in bytes.
Notes: This method will return the size of a file from the File List dialog. Using this method you can check to make sure that a file is not too large or simply display the size along with other information.
Example: The following JavaScript code will display the size of the first file in the File List dialog:

alert('Size of the first file is ' + document.FileUpload.getFileSize(i));

getIncludeDate

getIncludeDate()

Returns a flag indicating if file dates will be included with the upload.

Returns: Boolean flag.
Notes: This method will return the current setting of the IncludeDate flag as specified by the last call to setIncludeDate or the setting of the includeDate parameter.
Example: The following JavaScript code will check to see if IncludeDate is turned on:

if (document.FileUpload.getIncludeDate())
    alert('IncludeDates is on');
else
    alert('IncludeDates is off');

getIncludeMD5

getIncludeMD5()

Returns a flag indicating if MD5 checksums of each file will be included with the upload.

Returns: Boolean flag.
Notes: This method will return the current setting of the IncludeMD5 flag as specified by the last call to setIncludeMD5 or the setting of the includeMD5 parameter.
Example: The following JavaScript code will check to see if IncludeMD5 is turned on:

if (document.FileUpload.getIncludeMD5())
    alert('IncludeMD5 is on');
else
    alert('IncludeMD5 is off');

getUploadProgress

getUploadProgress()

Returns the progress of an upload request.

Returns: Integer having one of the following values:

Value Description
100 Upload completed successfully, 100% complete.
0-99 Upload inprogress where value is the percent complete.
-1 Upload not inprogress.
-2 Upload failed or cancelled.

Notes: The submit method starts the upload asynchronously. This means the call to submit will return before the upload request has finished. Using the getUploadProgress method and window.setTimeout you can poll for completion of the upload and determine if it was successful or not.
Example: The following JavaScript function checks to see if the upload completed:

function checkUpload()
{
    var status = document.FileUpload.getUploadProgress();
    if (status >= 0 && status < 100)
        window.setTimeout('checkUpload()', 200);
    else
        alert('Upload completed ' + 
              (status < 0 ? 'unsuccessfully' : 'successfully') );
}

getUploadStatus

getUploadStatus()

Returns the status text of an upload.

Returns: String containing the status text of the upload.

Notes: Used in conjunction with the getUploadStatus method, this method is useful for retrieving status information about an upload that is inprogress.
Example: The following JavaScript code displays the current status of an upload.

alert('Upload status = ' + document.FileUpload.getUploadStatus());

hasChanged

hasChanged()

Returns a flag indicating if files have been added or removed from the File List dialog.

Returns: Boolean flag.
Notes: This method can be used to check for changes to the File List dialog so that you can perform your own display and validation. The best way to use this function is with window.setTimeout allowing you to poll for changes as they occur.
Example: The following JavaScript function checks to see if there are changes:

function checkFileList()
{
    if (document.FileUpload.hasChanged())
        alert('File List has changed!');
    window.setTimeout('checkFileList()', 200);
}

hasInitialized

hasInitialized()

Returns a flag indicating if the applet has finished initializing.

Returns: Boolean flag.
Notes: This method can be used to check to see if the applet has finished initializing before attempting to make other scripting calls. The best way to use this function is with window.setTimeout allowing you to poll until the applet has finished initializing.
Example: The following JavaScript function checks to see if there are changes:

function waitForInit()
{
    if (document.FileUpload.hasInitialized())
    {
        alert('Applet has loaded!');
             :
           // Perform custom initialization
             :
    }
    else
        window.setTimeout('waitForInit()', 200);
}

removeFile

removeFile(index)

Removes a file from the File List dialog.

Parameter Description
index Number specifying the position (starting at 1) of the file

Returns: Nothing.
Notes: This method will remove the file at the given position from the File List dialog. This method is useful for removing a specific file during validation. It can also be used to implement your own custom File List. To remove all the files in a single call, use the clearFiles method.
Example: The following JavaScript code will remove the first file from the File List dialog:

document.FileUpload.removeFile(1);

select

select()

Show the File List dialog.

Returns: Nothing.
Notes: This method is useful for associating a button or link on your HTML page with the File List dialog. It can be used when the noFileList parameter is set to true to display the File List dialog as a separate window. If the noFileList parameter is not set to true, this method does nothing.
Example: The following tag will add an 'Attach' button to a form that will display the File List dialog

<INPUT TYPE="button" VALUE="Attach" onClick="document.FileUpload.select()">

selectAdd

selectAdd()

Show the Browse dialog to allow user to add files.

Returns: Nothing.
Notes: Calling this method is equivalent to the user pressing the Add button. This method should be used in conjunction with the noAdd parameter to implement your own custom Add button.
Example: The following tag will add a 'Browse' button to a form that will bring up the file selection dialog when pressed.

<INPUT TYPE="button" VALUE="Browse..." onClick="document.FileUpload.selectAdd()">

selectRemove

selectRemove()

Allow user to remove files from the File List dialog.

Returns: Nothing.
Notes: Calling this method is equivalent to the user pressing the Remove button. This method should be used in conjunction with the noRemove parameter to implement your own custom Remove button.
Example: The following tag will add a 'Delete' button to a form that will remove selected files when pressed.

<INPUT TYPE="button" VALUE="Delete" onClick="document.FileUpload.selectRemove()">

setAutoZip

setAutoZip(flag)

Parameter Description
flag Boolean flag to enable or disable ZIP compression

Sets a flag indicating if files will be zipped during upload.

Returns: Nothing.
Notes: This method can be used to set or clear the AutoZip flag that controls whether files are compressed into a ZIP during upload. This method is useful for dynamically controlling this option through user input or your own scripting logic.
Example: The following JavaScript code will turn AutoZip on:

document.FileUpload.setAutoZip(true);

setBrowseTitle

setBrowseTitle(title)

Parameter Description
title String containing the text to display as the title

Sets the current title of the Browse dialog.

Returns: Nothing
Notes: This method will set the current title of the Browse dialog. This is useful for giving users a better idea of what type of file you want them to select.
Example: The following JavaScript code will change the browse dialog title:

document.FileUpload.setBrowseTitle("Please select a single text file");

setDirectory

setDirectory(path)

Parameter Description
path String containing the new directory path

Sets the current directory of the Browse dialog.

Returns: String containing the directory path.
Notes: This method will set the current directory of the Browse dialog for the next time the dialog is displayed. This method is equivalent to setting the directory parameter, but can be used to dynamically change the directory based on your own scripting logic.
Example: The following JavaScript code will set the current directory:

document.FileUpload.setDirectory("C:\My Documents");

setFileMask

setFileMask(mask)

Parameter Description
mask String containing the new file mask

Sets the current file mask of the Browse dialog.

Returns: String containing the file mask.
Notes: This method will set the current file mask of the Browse dialog for the next time the dialog is displayed. This method is equivalent to setting the fileMask parameter, but can be used to dynamically change the directory based on your own scripting logic.
Example: The following JavaScript code will set the current file mask:

document.FileUpload.setFileMask("*.dat");

setIncludeDate

setIncludeDate(flag)

Parameter Description
flag Boolean flag to enable or disable including last modified dates in the upload

Sets a flag indicating if file modification dates will be included in the upload.

Returns: Nothing.
Notes: This method can be used to set or clear the IncludeDate flag that controls whether the last modified dates of files are including with the upload. This method is useful for dynamically controlling this option through user input or your own scripting logic.
Example: The following JavaScript code will turn IncludeDate off:

document.FileUpload.setIncludeDate(false);

setIncludeMD5

setIncludeMD5(flag)

Parameter Description
flag Boolean flag to enable or disable including MD5 checksums in the upload

Sets a flag indicating if MD5 checksums will be included in the upload.

Returns: Nothing.
Notes: This method can be used to set or clear the IncludeMD5 flag that controls whether MD5 checksums will be included in the upload. This method is useful for dynamically controlling this option through user input or your own scripting logic.
Example: The following JavaScript code will turn IncludeMD5 on:

document.FileUpload.setIncludeMD5(true);

submit

submit(document, form, valid)

Submit the files and form data to the server.

Parameter Description
document The document area to display the upload response.
form The form object representing the form to be submitted along with the selected files.
valid A boolean expression or function that evaluates to true if the form data is valid.

Returns: false
Notes: This method should be called from the onSubmit event for the form in which case the variable document can be used for the document parameter and the variable this can be used for the form parameter. The valid parameter is useful if you need to do any form data validation in your onSubmit event. In this case simply include the validation expression inside the submit call as the third parameter. If you do not need any validation, simply set this parameter to true.
Example 1: The following form tag will submit the form along with the selected files to the server

<FORM ACTION="upload.asp" 
onSubmit="return document.FileUpload.submit(document,this,true)">

Example 2: The following form tag will submit the form after calling your validation function validate()

<FORM ACTION="upload.asp" 
onSubmit="return document.FileUpload.submit(document,this,validate())">