Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML DOM FileUpload object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


HTML DOM FileUpload object


FileUpload object

In HTML documents, a FileUpload object is created for every time a label appears.

The element contains a text input field for entering the file name and a button to open the file selection dialog box to graphically select the file.

The value property of the 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, not just the file name.

For security reasons, the file-upload element does not allow the HTML author or JavaScript programmer to specify a default file name. T he HTML value property is ignored, and for such elements, the value property is read-only, which means that 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 handle.

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


FileUpload object properties

W3C: W3C standard.

Attributes describe W3C
disabled Set or return to whether the fileUpload object is disabled. Yes
accept Set or return a list of MIME types that indicate file transfer (comma separation). Yes
form Returns a reference to a form containing the fileupload object. Yes
name Set or return the name of the fileupload object. Yes
type Returns the type of a table element.For FILEUPLOAD, it is "file". Yes
value Returns the file name of the fileupload object after the text is set by the user. Yes

Standard properties and events

FileUpload objects also support standard properties and events.