input type="file" ElementThe input type="file" element is an inline element declared by the XHTML 1.1 Forms Module but is not present in the
*W3C XHTML 1.1 Basic Forms Module
Elements in the Forms Module are:form | label | textarea | select | optgroup | option | button | fieldset | legend | input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"
The input type="file" element allows
a file on the user's computer to be uploaded as part of a
form submission.
In order to make use of file upload controls, the enclosing
form element's enctype
attribute should be given the value "multipart/form-data" and its
method attribute the value "post". This allows the content of the file to be
sent with the request. The server at the form's
processing URI (specified in its action
attribute) must take care of the request and store the uploaded file
in the appropriate location, if required.
An example file upload control:
Note: I have not included
value,
readonly or
maxlength
attributes among the Specific Attributes on this page
because browser support for these attributes is not consistent. In the
case of the value
attribute, which would give the page author the ability to specify a default file
for upload (potentially without the user being aware of the upload taking
place) presents such a security risk that almost all user agents ignore the
contents of any value
attribute on the input type="file" element.
The maxlength
attribute is also usually ignored (understandably, since the length of a file's
filename is what it is and would not specify the location of the file correctly
were it to be truncated!) and the
readonly attribute
gets only partial, if any, support in the majority of browsers (since I can't
actually imagine a situation in which I would want to use this attribute, this
doesn't strike me as a problem).
See also the overview of all
input elements.
Although the type attribute is not #REQUIRED
on the input element, its default value is "text" and so must be present on input type="file".
input type="file" element are listed below:accept [ type ContentTypes ]form's processing scriptaccesskey [ type Character ]input element to allow a file to be selecteddisabled [ type Boolean ]name [ type CDATA ]name attribute is not present, the file data will not be sent). The value sent (in a name=value pair) is the filename selected (but bear in mind that some user agents will send the full path name and some just the name of the file itself).To get file upload: In order to make use of file upload controls, the form element's enctype should be set to "multipart/form-data" and its method to "post" - this allows the content of the file to be sent with the request
Note: Although technically optional, a note in the *Forms Module DTD says that the name attribute is required on all input elements except "submit" and "reset"
size [ type Number ]tabindex [ type Number ]onblur [ type Script ]onchange [ type Script ]onfocus [ type Script ]onselect [ type Script ]input type="file" element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
input type="file" element is:
EMPTY
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
input type="file"This element is empty and may have no children.
input type="file"abbr, acronym, address, cite, code, dfn, div, em, h1 - h6, kbd, p, q, samp, span, strong, varadd, dt, licaption, td, thfieldset, label, legendb, big, i, small, sub, sup, ttdel, insbdoobjectrb, rt