Home >
Article > Web Front-end > Introduction to the role and application examples of the Enctype attribute of the Form form tag_HTML/Xhtml_Web page production
Introduction to the role and application examples of the Enctype attribute of the Form form tag_HTML/Xhtml_Web page production
- WBOYOriginal
- 2016-05-16 16:37:421638browse
enctype=" in the form multipart/form-data" means setting the MIME encoding of the form. By default, this encoding format is application/x-www-form-urlencoded, which cannot be used for file upload; only when multipart/form-data is used, file data can be transferred completely.
enctype="multipart/form-data" is to upload binary data.
If you want to obtain the value of the corresponding form field through the Request object on the server side, you should set the enctype attribute to the application/x-www-form-urlencoded value (that is, the default value, the setting does not need to be displayed).
Why do you need to set enctype="multipart/form-data" when uploading files:
Because: after setting enctype to the multipart/form-data value, the characters are not encoded, and the data is in binary form Transmitted to the server. At this time, if you use request, you cannot directly obtain the value of the corresponding form. Instead, you should use the stream object to decode the binary data transmitted to the server to read the data.
If you want to upload files, you must set the encotype to multipart/form-data.