HTML/Elements/input/file

From W3C Wiki
< HTML‎ | Elements‎ | input
Jump to: navigation, search

<input type="file">

The file state represents a list of selected files, each file consisting of a file name, a file type, and a file body (the contents of the file).

Point

  • Unless the multiple attribute is set, there must be no more than one file in the list of selected files.


HTML Attributes

  • accept = list of MIME types
    Specified to provide user agents with a hint of what file types will be accepted. [Example A]


  • multiple = boolean
    Indicates whether the user is to be allowed to specify more than one value.


  • name = string
    Gives the name of the input element.


  • required = boolean
    When specified, the element is required.


  • value = string
    Gives the default value of the input element.


Example

Example A

[try it]

<label>Select file: <input type="file" name="imagefile" accept="image/jpeg, image/png"></label>
<input type="submit" value="upload">

Input file01.png

HTML Reference

The HTML5 specification defines the File state in 4.10.7.1.18 FILE STATE.