Javascript » Objects » FileUpload

A FileUpload object provides a field in which the user can enter a file name to be uploaded and used as input and is created with every instance of an HTML <INPUT> tag (with the 'type' attribute set to 'file') on a form. These objects are then stored in the elements array of the parent from and accessed using either the name defined within the HTML tag or an integer (with '0' being the first element defined, in source order, in the specified form).

Properties

Form Property

Syntax: object.form

This property returns a reference to the parent Form of the FileUpload object.

Name Property

Syntax: object.name

This property sets or returns the value of the FileUpoad object's name attribute.

Type Property

Syntax: object.type

Every element on a form has an associated type property. In the case of a FileUploadobject, the value of this property is always 'file'.

Value Property

Syntax: object.value 

This property sets or returns the FileUpload object's value attribute. This is a string input by the user that specifies the file to upload.

Methods

blur Method

Syntax: object.blur( )

This method removes the focus from the specified FileUpload object.

click Method

Syntax: object.click( )

This method simulates a mouse-click on the FileUpload object.

focus Method

Syntax: object.focus( )

This method gives focus to the specified FileUpload object.

handleEvent Method

Syntax: object.handleEvent(event)

This method calls the handler for the specified event.

focus Method

Syntax: object.focus( )

This method gives focus to the specified FileUpload object.

Event handlers

onBlur Event handler

Syntax: object.onBlur="myJavaScriptCode" 

This event handler executes some specified JavaScript code on the occurrence of a blur event (when the FileUpload object loses focus).

onChange Event handler

Syntax: object.onClick="myJavaScriptCode" 

This event handler executes some specified JavaScript code on the occurrence of a click event (when the FileUpload object loses focus and its value has altered).

onFocus  Event handler

This event handler executes some specified JavaScript code on the occurrence of a focus event (when the FileUpload object receives focus).