- Attribute of
- <form> HTML Tag
- What does
- The enctype attribute lets you specify an encoding type for your form.
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.
<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>
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.
Browser Support for enctype