• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Html » Tutorial » HTML input type=”file” Attribute
Next →
← Prev

HTML input type=”file” Attribute

By Dinesh Thakur

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.

Syntax  <INPUTtype="file"name="field-id"size="n"accept="file-type">

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.

<html> 
<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> 
<selectname="country"> 
<optionvalue="india">india 
<optionvalue="america"> america 
<optionvalue="australia"> australia 
<optionvalue="new zealand"> new zealand 
<optionvalue="china"> china 
</select><b>country</b> 
<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"> 
</form> 
</body> 
</html>

You’ll also like:

  1. HTML input type=”hidden” Attribute
  2. Html Input Type
  3. HTML Global accesskey Attribute
  4. File input Stream and File Output Stream
  5. Write a Program to Count Vowels in a File Using File Handling
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

HTML Tutorials

HTML Tutorials

  • HTML - Home
  • HTML - History
  • HTML - Lists
  • HTML - Unordered List
  • HTML - Ordered Lists
  • HTML - Frame Tag
  • HTML - Input Type
  • HTML - Input Type="File"
  • HTML - Input Type="Hidden"
  • HTML - Form Tag
  • HTML - Img Tag
  • HTML - Anchor Tag
  • HTML - Table Tag
  • HTML - Span Tag
  • HTML - Button Tag
  • HTML - Doctype
  • HTML - Fieldset Tag
  • HTML - Links Tag
  • HTML - Drop Down Menu
  • HTML - Accesskey
  • HTML - Cgi
  • HTML - Post Method
  • HTML - Background Image
  • HTML - Text Area
  • HTML - TabIndex
  • HTML - Align Center
  • HTML - Address Tag
  • HTML - Thumbnails
  • HTML - Marquee Tag
  • HTML - Line Break
  • HTML - Blockquote
  • HTML - HR Tag
  • HTML - Image Center
  • HTML - Center Text
  • HTML - Link CSS
  • HTML - Html Vs Html5

Other Links

  • HTML - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW