The attribute enctype
is responsible for defining how the data of the forms will be encoded when they are submitted, and also only works with the POST
.
There are currently 3 values that can be specified in this attribute:
- application/x-www-form-urlencoded
- Multipart/form-date
- text/Plain
The application/x-www-form-urlencoded
is the default value for the enctype
if none is specified, and if in use, all characters are encoded before being sent.
Where a multipart/form-data
as a 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 the guy form-data
, and with an additional parameter name
whose value is the name of the field.
Finally has the text/plain
that converts the spaces into +
, 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 typed 'Joe should
100 "where the euro symbol may have returned form data 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 coding multipart/form-data
has high overhead and some impact on performance if there are too many fields with low values. But in practice this overload is not significant. If you really want more details, or it is not clear enough, you will need to read this and some of the other Rfcs for a better analysis of gains and losses. Another good font would be this page here of W3.
Actually, I did the test with a form with two fields in both modes. No
multipart/form-data
the content-length of the post got much bigger. I believe the only problem then is performance. Thank you.– Fernando Camillo