I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded
and multipart/form-data
. I understand that I use multipart/form-data
when I need to upload a file. When do I use application/x-www-form-urlencoded
? Is it default form enctype?
The application/x-www-form-urlencoded content type describes form data that is sent in a single block in the HTTP message body. Unlike the query part of the URL in a GET request, the length of the data is unrestricted.
Hence, it is advised to use x-www-form-urlencoded when you have to send form data e.g. most of the web form which asks you to enter values and use multipart/form-data when you have to upload files to the server as used here.
Encoding TypesBlank spaces are encoded with + symbols, unsafe characters are encoded by their hexadecimal values preceded by % symbols. All popular browsers use this encoding type for form submissions, both for URL query strings (HTTP method GET ) and HTTP request bodies (HTTP method POST ).
Security considerations: In isolation, an application/x-www-form-urlencoded payload poses no security risks. However, as this type is usually used as part of a form submission, all the risks that apply to HTML forms need to be considered in the context of this type.
Yes, it is. Here's a cite from the W3 HTML forms specification:
The default value for this attribute is
"application/x-www-form-urlencoded"
. The value"multipart/form-data"
should be used in combination with theINPUT
element,type="file"
.
The webbrowser will take care about URL encoding automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With