HTML DOM Input FileUpload Object

Input FileUpload object

The Input FileUpload object represents an HTML <input> element with type="file" set.

Access Input FileUpload Object

You can access the <input> element of type="file" using getElementById():

var x = document.getElementById("myFile");

Try It Yourself

Tip:You can also search the form for elements collection to access <input type="file">.

Create Input FileUpload Object

You can create an <input> element of type="file" using the document.createElement() method:

var x = document.createElement("INPUT");
x.setAttribute("type", "file");

Try It Yourself

Input FileUpload Object Properties

Properties Description
accept Set or return the value of the accept attribute of the file upload button.
autofocus Set or return whether the file upload button should automatically focus when the page is loaded.
defaultValue Set or return the default value of the file upload button.
disabled Set or return whether the file upload button is disabled.
files Return a FileList object that represents one or more files selected using the file upload button.
form Return a reference to the form that contains the file upload button.
multiple Set or return whether multiple files can be selected in the file upload field by the user.
name Set or return the name attribute value of the file upload button.
required Set or return whether the file upload field must be selected before submitting the form.
type Return which type of form element the file upload button is.
value Return the path or name of the selected file.

Standard properties and events

The Input FileUpload object supports both standardPropertiesandEvents.

Related Pages

HTML Tutorial:HTML Form

HTML Reference Manual:HTML <input> Tag

HTML Reference Manual:HTML <input> type Attribute