<input> - file

HTML DOM FileUpload object

FileUpload object

Each time the <input type="file"> tag appears in an HTML document, a FileUpload object is created.

This element contains a text input field for entering a filename and a button for opening a file selection dialog for graphical selection of files.

The value attribute of this element holds the name of the file specified by the user, but when a form containing a file-upload element is submitted, the browser sends the contents of the selected file to the server instead of just the file name.

For security reasons, the file-upload element does not allow HTML authors or JavaScript programmers to specify a default filename. The HTML value attribute is ignored, and for such elements, the value attribute is read-only, which means that only the user can enter a filename. When the user selects or edits a filename, the file-upload element fires the onchange event handler.

You can access the FileUpload object by iterating over the form's elements[] array, or by using document.getElementById().

FileUpload Object Attributes

W3C: W3C standard.

disabledSets or returns whether to disable the FileUpload object.Yes
acceptSet or return a comma-separated list of MIME types that indicate file transfersYes
formReturns a reference to the form that contains the FileUpload object.Yes
nameSets or returns the name of the FileUpload object.Yes
typeReturns the type of form element. For FileUpload, it is "file".Yes
valueReturns the file name of the FileUpload object after the text set by the user input.Yes

Standard Properties and Events

FileUpload objects also support standard properties and events .