Alternate useage of FileUpload Control

I am following the ‘advice’ of the help file concerning the usage of the javascript object model so that I can manipulate the name of the FileUploadControl (actually so that I can validate that there is a value in the input field before submission)

“The FileUpload object has no direct representation as a Domino field type. You can generate this object in a browser by creating a field (for example, of type Text) and specifying “INPUT TYPE=file” for “Other” under the HTML tab. A FileUpload object cannot be accessed in the Notes client.”

However, I don’t think this works as I am expecting it to. I expected the fileuploadcontrol to behave like the embedded control, but instead, I just get a text field that has the name of the selected file when I submit the form.

If there is something I am doing wrong, or if someone else has a method for checking the value of a typical domino generated FileUploadControl field, I would really appreciate the help.

Subject: Alternate useage of FileUpload Control…

You don’t need to get the upload directly – which is a blessing if you have to work with older browsers. The file upload control, if used singly on a form, will have an id value of “fileUpload”, so in modern (DOM-compliant) browsewrs, you can access it using document.getElementById(‘fileUpload’).value. For older browsers, you need to loop through the fields to get it:

function getFileName() {

var f = document.forms[0];

for (i=0;i<f.elements.length;i++) {

if (f.elements[i].type == “file”) {

return f.elements[i].value;

}

}

}

If you have more than one file upload, you can continue through the elements collection, adding the values to an output array as they are found.

Subject: RE: Alternate useage of FileUpload Control…

Thanks…I’ll give it a try ASAP.

I am only using a single file control in this current project, but might have need for this with multiples and had thought about looping through the elements, but thought also that there might be a quicker and cleaner way to get the input names.

Where did you find the reference to fileUpload? Is that a javascript thing or a name supplied by Domino automatically?

Subject: RE: Alternate useage of FileUpload Control…

The id is set on the tab of the control properties. The name is set by Domino, but as you’ve seen it is an offset reference that you’d have one heck of a time trying to maintain in JavaScript. (To tell the truth, I had forgotten that I’d set it myself – I was looking at the View-Source for the HTML form when I responded initially. Sorry 'bout that, Chief.)

Subject: RE: Alternate useage of FileUpload Control…

I stilled couldn’t get your first solution to work (fileUpload), but I did get the second method to work…

Thanks again.