HTML CSS examples for HTML Tag:input
The file type of input element uploads files to the server as part of the form submission.
This type of input supports the additional attributes shown in the following table.
Attribute | Description | New in HTML5 |
---|---|---|
accept | Specifies the set of mime-types that will be accepted. RFC2046 defines MIME types (http://tools.ietf.org/html/rfc2046). | No |
multiple | specifies that the input element can upload multiple files. | Yes |
required | Specifies that the user must provide a value for the purposes of input validation. | Yes |
Using the file Type of the input Element to Upload Files
<!DOCTYPE html> <html> <head> <title>Example</title> </head> <body> <form method="post" action="http://example.com/form" enctype="multipart/form-data"> <input type="hidden" name="recordID" value="1234"> <p> <label for="name"> Name: <!--from w w w . j av a 2 s .co m--> <input value="java2s.com" id="name" name="name"> </label> </p> <p> <label for="password"> Password: <input type="password" placeholder="Min 6 characters" id="password" name="password"> </label> </p> <p> <label for="fave"> Favorite Fruit: <input type="text" id="fave" name="fave"> </label> </p> <p> <input type="file" name="filedata"> </p> <input type="submit" value="Submit"> </form> </body> </html>