You are here: Reference > HTML > tags > input:file

input:file element

Browser support:
Creates a file selector object with a single-line text input control and a browse button.
With this control you can allow file uploading to a server. Clicking on the browse button opens the operating system dependent file dialog that allows the user to select a file to upload.

By default, the file selection control only supports single file selection, but with the MULTIPLE attribute, you can allow users to select more than one file with one file selection control.

This control is one of the form controls.
The selected files can be submitted to a server if the following conditions are met:
  • A form element must contain the file selection control.
  • The action attribute of the container form must be set to the URL of the server.
  • The method attribute of the container form must be set to 'post'.
  • The encType attribute of the container form must be set to 'multipart/form-data'.
  • The name attribute of the file selection control must be specified and non-empty.
For detailed information about file uploading in PHP, visit these sites: Handling file uploads (php.net), PHP File Upload (w3schools)
If you want to see the HTML tags by categories, please visit this page.
This element cannot have a closing tag.
JavaScript page for this element: input:file.

Possible members:

Attributes
Events
Styles
Pseudos
accept
Sets a comma-separated list of accepted content types.
accessKey
Sets an access key to an element.
class
Sets the style class or classes that belong to the element.
contentEditable
3
Sets whether the contents of the object are editable.
dir
Sets the text direction as related to the lang attribute.
DISABLED
Sets the state of an object for user interaction.
HIDEFOCUS
Specifies whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
hSpace
Specifies the number of pixels to use as a margin at the left and right sides of the object.
id
Sets a unique identifier for the object.
lang
Specifies the language of the element.
language
Sets the scripting language for the current element. Use it only for the script element.
MULTIPLE
3.6
Sets whether more than one file can be selected with the current input:file element.
name
Sets the name of a form control that affects the contents of the message submitted to the server.
READONLY
Sets whether the contents of the element are changeable.
size
Specifies the width of a control, in characters.
style
Sets an inline style associated with an element.
tabIndex
Specifies the tabbing order for keyboard navigation using the TAB key.
title
Specifies a tooltip for an element.
type
Sets the type of the input element.
unSelectable
9
Sets whether the selection process can start in an element's content.
vSpace
Specifies the number of pixels to use as a margin at the top and bottom sides of an object.

Example HTML code 1:

This example illustrates the use of the file selection element:
<form method="post" enctype="multipart/form-data" action="#URL#">
    Select a file: <input type="file" name="uploadFile" size="25" />
    <br /><br />
    <input type="submit" value="Upload" />
</form>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content