Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM FileUpload Object

HTML DOM FileUpload Object


FileUpload Object

In an HTML document, A FileUpload object is created each time a tag appears.

This element contains a text input field for entering a file name, and a button that opens a file selection dialog for graphically choosing a file.

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 content of the selected file to the server, not just the file name.

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

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


FileUpload Object Properties

W3C: W3C standard.

property Description W3C
disabled Sets or returns whether the FileUpload object is disabled. Yes
accept Sets or returns a list of MIME types indicating allowed file transfers (comma-separated). Yes
form Returns a reference to the form containing the FileUpload object. Yes
name Sets or returns the name of the FileUpload object. Yes
type Returns the type of the form element. For FileUpload, this is "file". Yes
value Returns the file name of the FileUpload object after it has been set by the user's input. Yes

Standard properties and events

The FileUpload object also supports standard property and Events.