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

Mar 25, 2017 pm 02:43 PM

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to post pictures on Douyin comments How to post pictures on Douyin comments Feb 19, 2024 pm 01:10 PM

As one of the most popular short video sharing platforms in the world, Douyin has attracted hundreds of millions of users to join it. When looking at other people's wonderful works, we are often moved by some dynamic, interesting or meaningful moments in them. At this time, we can not only express our opinions and thoughts through text comments, but also express our emotions more vividly through picture comments. So, how to post picture comments on TikTok? First, open the Douyin APP and enter the video you are interested in. Next, we need to determine the operating system of the mobile phone according to the different

In HTML, what does enctype='multipart/form-data' mean? In HTML, what does enctype='multipart/form-data' mean? Aug 22, 2023 am 08:53 AM

Use the enctype attribute to specify how the browser encodes data before sending it to the server. Possible values ​​are -application/x-www-form-urlencoded− This is the standard approach used by most forms in simple scenarios. mutlipart/form-data− This is used to upload binary data in forms, such as images, Word files, etc. ExampleNow let us look at an example −&lt;!DOCTYPEhtml&gt;&lt;html&gt;&lt;head&gt;&lt;title&am

BinaryX is renamed FORM again, and the FOUR it gives to the community is about to soar? BinaryX is renamed FORM again, and the FOUR it gives to the community is about to soar? Mar 04, 2025 pm 12:00 PM

BinaryX's token name change: from BNX to FOUR, and then to FORM, the deep meaning behind strategic adjustments BinaryX recently changed the token symbol from $FOUR to $FORM, which has attracted widespread attention from the industry. This is not the first time BinaryX has changed its name, and its token symbol has undergone a transition from BNX to FOUR. This article will explore in-depth the strategic intentions behind this series of name change. 1. Token name change process and strategic considerations BinaryX initially launched the $BNX token based on the BNB chain in 2021 to support its Play-to-Earn (P2E) gaming ecosystem. In early 2024, in order to optimize the economic model, BinaryX divided $BNX and gradually expanded to GameF

Can there be multiple forms in html5? Can there be multiple forms in html5? Aug 01, 2022 pm 05:28 PM

There can be multiple forms in html5. The rules allow multiple form tags to be used in the same HTML page. However, in order to prevent the backend from not recognizing it when submitting, you need to add different IDs or classes to the form. The syntax is "<from action="url" id=" id value 1">Form element</from><from action="url" id="id value 2">Form element</from>.....".

What is the tag that defines the form in html5 What is the tag that defines the form in html5 Jul 26, 2022 pm 04:26 PM

The tag defining a form in HTML5 is "<form>". The form tag is used to create an HTML form (form field) for user input to collect and transfer user information. All content in the form will be submitted to the server; the syntax "<form action="Submit Address" method="Submit Method " name="form name">form control</form>". A form can contain one or more form elements, such as input, select, and textarea.

Comprehensively organize elements related to form forms! Comprehensively organize elements related to form forms! Aug 05, 2022 am 11:45 AM

This article gives you a detailed summary of the knowledge points related to form elements in HTML. I hope it will be helpful to you!

Let's talk about how to use php to upload images Let's talk about how to use php to upload images Mar 28, 2023 am 11:28 AM

With the development of the Internet, image uploading has become one of the most common functions in website development. It is very simple to use the PHP language to implement the image upload function. As long as you have a certain basic knowledge of PHP, you can easily complete this task. This article will introduce how to use php to upload images

Let's talk about how to use ueditor to upload pictures and add watermarks Let's talk about how to use ueditor to upload pictures and add watermarks Aug 31, 2022 am 10:35 AM

How to upload pictures with ueditor and add watermark? The following article will introduce to you how to use ueditor to upload pictures and add watermarks in PHP. I hope it will be helpful to you!

See all articles