XHTML » input » type="file"

The type="file" control is used to attach a file to a form. When the form is submitted, the file is passed along with all the other contents of the form.

This control displays an input window and a browse button. By clicking on the browse button, the user can search your directories for the desired file. When you find it, a double mouse click will select the file. Alternately, you can enter the path and name of the file into the input window. A value for the name attribute is required. You do not use the value attribute.

To use the type="file", you must set both the enctype and method attributes of the form tag exactly as shown in the this code snippet.

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML input Tag Example</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="next.html">
<input type="file" name="file1" />
</form>
</body>
</html>
Output:
Language(s): HTML