What does enctype=’multipart/form-data’ mean in a form
·Sep 25, 2014·
1 min read
Play this article
HTML forms provide three methods of encoding.
application/x-www-form-urlencoded- Represents an URL encoded form. This is the default value if enctype attribute is not set to anything.
multipart/form-data- Represents a Multipart form. This type of form is used when the user wants to upload files
text/plain- A new form type introduced in HTML5, that as the name suggests, simply sends the data without any encoding
The specifics of the formats don’t matter to most developers.
The important points are:-
- When you are writing client-side code, all you need to know is use
multipart/form-datawhen your form includes any
- When you are writing server-side code: Use a prewritten form handling library
CGI->paramor the one exposed by PHP’s
$_POSTsuperglobal) and it will take care of the differences for you. Don’t bother trying to parse the raw input received by the server.