Getting a Handle on File Upload Control

Author: Tripp W Black

Created: 10/17/2000 at 04:34 PM


Notes Developer Tips
Forms/Subforms, JavaScript

File upload controls created on forms are not easily accessible on the web because the name of the control is generated by domino thus preventing a developer the ability to assign a name to this control while designing. The only way the upload control can be accessed on the web is by looking for the item type and the position of the file upload control on the form. This problem is further aggrevated in the case of multiple file upload controls on the form.

Here is a simpler solution to the problem:
1.) Create a file upload control on the form.
2.) Open the property box for this control.
3.) Go to the <HTML> tab.
4.) In the Others field enter the following JavaScript:

onFocus="GetName(this)" onBlur="GetName(this)"

5.) In the JSHeader event for the form, create the following function:

var itmHndl ;   //A global Script Variable that would hold the name of the file upload control.
//So we  need to have a separate global variable for every File Upload control on the form.

Function GetName(itm) {
   itmHndl = itm;
   ///to access the value..i.e the selected file path
   ///eg: "c:\temp\tst.gif"

Uisng this function, the handle to the upload control would now be accessible from anywhere on the page allowing programmatic access to the file upload control.

The Global Script Variable (itmHndl) can also be replaced by a hidden field for every file upload control on the form. Since we would know the name of the hidden field, we can set its value in the above-mentioned fashion.

previous page