HTML enctype Attribute
Example
<form action="action.php" enctype="application/x-www-form-urlencoded">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br>
<input type="submit" value="Submit">
</form>
Meaning
The enctype attribute specifies how form data should be encoded before being sent to the server.
The default is application/x-www-form-urlencoded. This encoding replaces blank characters in the data with a plus character (+) and all other nonprinting characters with a percent sign (%) followed by the character’s ASCII HEX representation.
The multipart/form-data option does not perform character conversion and transfers the information as a compound MIME document. This must be used when using <input type="file">.
It also might be possible to use another encoding, such as text/plain with a mailed form, but in general you should be cautious about changing the enctype.
Standard Syntax
<element enctype="application/x-www-form-urlencoded|multipart/form-data|text/plain">
Browser Support
Status
Applies to:
The enctype attribute can be used on the following element:
Attribute Values
Value | Description |
---|---|
application/x-www-form-urlencoded | (Default) All characters will be encoded before sending data. |
multipart/form-data | This value is necessary if the upload a file through the form. (img, video, etc...) |
text/plain | Sending data without any encoding. (Not recommended) |