by Dinesh Thakur Category: HTML

HTML also supports a special input field, a file field, to allow visitors to upload files. If you want visitors to submit information - say a picture, a spreadsheet, a word-processed document or a scanned document, they can use this field to simply upload the file with the hassle of using FTP or e-mail the file.



Name: To label the field.

Size: To specify the physical size of the field's input box.

Accept: To restrict the file types allowed in a file upload. For example add accept = "image/ gif" to occupy only gif files

To include files of some specific types, just separate them by commas. For example to include BOTH .gif and .jpeg files, the following code can be used.

Accept = "image/gif, image/jpeg"

When the form is loaded or reset, a button labeled "Browse" together with a text box for writing the file name appears on the window. As the user clicks on this button a new window “choose file” will open and the user can select the desired file. The following code will add a file field.


<head><title> text fields</title></head>
<body bgcolor="pink">
<p align="center"><b>admission form</b> <form> <p>
<inputtype="text"name="name"value="enter your name:"size="25"maxlength="30"> name<br><br> <inputtype="password"name="passwd"size="25"maxlength="30"><br><br> <inputtype="text"name="address"size="25"maxlength="30"> address<br><br> <inputtype="radio"name="sex"value="male"checked>male<br> <inputtype="radio"name="sex"value="female">female<br>
<optionvalue="america"> america
<optionvalue="australia"> australia
<optionvalue="new zealand"> new zealand
<optionvalue="china"> china
<textarea name="comments"rows=2cols=20wrap="virtual:"> place your comments here: </textarea> <b> comments </b>
<input type="file"name="attachements"size="30"accept="image/jpg"> <b> attachements</b> <palign=center>
<inputtype="image"src="c:\windows\hlpglobe.gif"alt="submit"width=55height=40> <input type="reset"value="reset">