Home > Web Front-end > HTML Tutorial > The role of enctype='multipart/form-data' in the form tag for uploading images in the form

The role of enctype='multipart/form-data' in the form tag for uploading images in the form

迷茫
Release: 2017-03-25 14:43:02
Original
3497 people have browsed it

When we use php to import and export excel tables, we often see enctype="multipart/form-data". What is its function?

ENCTYPE="multipart/form-data" is used to upload images in the form.


Set in the form tag enctype="multipart/form-data" to ensure correct encoding of anonymously uploaded files.
as follows:

<tr> 
  <td height="30" align="right">上传企业营业执照图片:</td> 
  <td><input type="file" name="uploadfile"  SIZE="34"    onChange="checkimage()"></td>  
</tr>
Copy after login

You must add ENCTYPE="multipart/form-data".

The meaning of enctype="multipart/form-data" in the form is to set 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, the file data can be completely transferred and the following operations can be performed.
enctype="multipart/form-data" is to upload binary data; the input value in the form is passed in binary. The input value in the form is passed in binary form, so the request will not get the value. That is to say, after adding this code, the request will be unsuccessful. When fetching the form value and adding it to the database, the following is used:

SmartUpload su = new SmartUpload();//Create a new SmartUpload object

su.getRequest().getParameterValues(); Get the array value

su.getRequest().getParameter( ); Get a single parameter and a single value

**************************************** *************************************************** ******

enctype="multipart/form-data"它的意思是以二进制的数据格式来传输,所以我们得到的数据是二进制的,必须再转换回string格式的数据。
Copy after login

The above is the detailed content of The role of enctype='multipart/form-data' in the form tag for uploading images in the form. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template