HTML Form Enctype


The enctype attribute on form tags specify how the form data should be encoded when delivered using the POST method.

<form enctype="value">

The enctype is a MIME type.

Default (application/x-www-form-urlencoded)

All characters are encoded before being sent. Spaces become + and special ones are converted to ASCII HEX values.

<form action="http://localhost:3333/post" method="post">
    <input type="text" value="Test, 1234" name="someInput">
    <input type="text" value="Ä und %" name="otherInput">
    <input type="submit">
</form>
someInput=Test%2C+1234&otherInput=%C3%84+und+%25

multipart/form-data

This one has to be set when sending files over a form.

<form action="http://localhost:3333/post" method="post" enctype="multipart/form-data">
    <input type="text" value="Test, 1234" name="someInput">
    <input type="text" value="Ä und %" name="otherInput">
    <input type="submit">
</form>
------WebKitFormBoundaryIu9hf318CXcd0tIK
Content-Disposition: form-data; name="someInput"

Test, 1234
------WebKitFormBoundaryIu9hf318CXcd0tIK
Content-Disposition: form-data; name="otherInput"

Ä und %
------WebKitFormBoundaryIu9hf318CXcd0tIK--

text/plain

Sends the form data without encoding. This is not recommended.

<form action="http://localhost:3333/post" method="post" enctype="text/plain">
    <input type="text" value="Test, 1234" name="someInput">
    <input type="text" value="Ä und %" name="otherInput">
    <input type="submit">
</form>
someInput=Test, 1234 otherInput=Ä und %