file selection box


<input type="file">

Browser
Internet Explorer Firefox Opera
Type
Inline-block Empty

The INPUT element defines an input field. When you specify "file" for the type attribute of this element, a file selection box is created.


<input type="file" name="example1">

<input type="file" name="example2" size="30">


Attribute Value Explanation
type=" " file the type of input field
name=" " field name a unique name for the field
size=" " number of chars the input field width

When the file selection box is used, the FORM element is set as follows.

<form method="POST" action="example.cgi" enctype="multipart/form-data">

method : POST
enctype : multipart/form-data

type="file"

Creates a file selection box on the form.

When the value of the type attribute is "file", the browse button is displayed next to the input box.

When this button is clicked, the file selection dialog box is displayed.

name=""

The field name is used to identify the form field.

size=""

The input field width is specified by the number of characters.

Tips and Notes

The style of the input field can be changed with CSS. Please see the "Related Document" for details on CSS.


Example

<form method="POST" action="example.cgi" enctype="multipart/form-data">

<p>Default<br>
<input type="file" name="example1"></p>

<p>size="40"<br>
<input type="file" name="example2" size="40"></p>

</form>
Output

Default

size="40"

This form cannot submit because of a sample.