The enctype
attribute is responsible for defining how form data will be encoded when it is submitted, and also only works with POST
.
There are currently 3 values that can be specified in this attribute:
- application / x-www-form-urlencoded
- multipart / form-data
- text / plain
The application/x-www-form-urlencoded
is the default value for enctype
if none is specified, and if it is in use, all characters are encoded before they are sent.
If the multipart/form-data
is set as the value for this attribute, no character is encoded. This type of request contains several parts, and each part of this request contains a content-diaposition
with type form-data
, and with an additional parameter name
whose value is the name of the field.
Lastly, it has text/plain
that converts spaces to +
, but does not encode anything.
According to RFC-2388 Each part of a multipart/form-data
must have a content type. In cases where the field is a text, the input character set indicates which encoding to use.
RFC-2388 - 4.5 -
For example, a form with a text field in which a user entered Joe must
100 ", where is the euro symbol can have form data returned As:
--AaB03x
content-disposition: form-data; name="field1"
content-type: text/plain;charset=windows-1250
content-transfer-encoding: quoted-printable
RFC-2388 - 5.2 -
The multipart/form-data
encoding has high overhead and some performance impacts if there are too many fields with few values. But in practice this overhead is not significant. If you really want more details, or are not clear enough, you will need to read this and some of the other RFCs for a better analysis of the gains and losses. Another good source would be here from w3.