Home  >  Article  >  Web Front-end  >  What is the use of using the enctype field when uploading files?

What is the use of using the enctype field when uploading files?

高洛峰
高洛峰Original
2017-02-23 13:17:401074browse

The enctype attribute of the FORM element specifies the encoding type used when submitting form data to the server. The default default value is "application/x-www-form-urlencoded".

This encoding method will urlencode the content before sending the form. (Spaces are converted to "+", and special characters are converted to ASCII HEX values).

For example, if we fill in bb as

firstname in the form field,

the result we get before sending is: bb+%2C%2C

However, this encoding is inefficient when sending large amounts of text, text containing non-ASCII characters, or binary data to the server.

When uploading files, the encoding type used should be "multipart/form-data", which can send text data and also supports binary data upload.

The ENCTYPE attribute value of the browser-side

form is multipart/form-data, which tells us that the data to be transmitted must use the multimedia transmission protocol. Since multimedia transmits a large amount of data, it is stipulated Uploading files must be the post method, and the type attribute of must be file.


For more form What is the use of using the enctype field when uploading files? For related articles, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn