Form Enctype HTML Code: Here's How It Specifies Form Encoding Type

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Attribute of
HTML Form Code For Beginners (And When To Use It)
What does Form Enctype HTML Code: Here's How It Specifies Form Encoding Type do?
The enctype attribute lets you specify an encoding type for your form.

The enctype attribute lets you specify an encoding type for your form. There are three possible values.

application/x-www-form-urlencoded is the default value if the enctype attribute is not specified. This is the correct option for the majority of simple HTML forms.

multipart/form-data is necessary if your users are required to upload a file through the form.

text/plain is a valid option, although it sends the data without any encoding at all. It is not recommended, as its behavior is difficult to predict.

Example Usage

<form action="fileupload.php" method="post" enctype="multipart/form-data">
<p>Please select the file you would like to upload.
   <input type="file" name="upload">
   <br>
   <input type="submit" value="Upload File">
</form>

File Uploads

In most cases, the default works very well, so it’s not necessary to specify an enctype. The one exception is any form where you invite file uploads. In this case, you must specify the multipart/form-data value for the enctype attribute for efficient and effective file transmission.

Claire is seasoned technical writer, editor, and HTML enthusiast. She writes for HTML.com and runs a content agency, Red Robot Media.

Browser Support for enctype

iefirefoxchromeedgesafariopera
AllAllAllAllAllAll