Form form enctype= ' Multipart/form-data '

Source: Internet
Author: User

Enctype= ' Multipart/form-data '

HTML forms provide three methods of encoding.

    • Application/x-www-form-urlencoded (the default)

    • Multipart/form-data

    • Text/plain

upload a file in the form <form> to add attributes enctype= "Multipart/form-data", many people just rote know upload form to write so, know it but do not know why.

So why do you add this property? What does it mean? What other optional values does it have?

In fact, the form form, when you do not write the Enctype property, also adds the Enctype property value to it by default, which is enctype= "application/x-www-form-urlencoded". This property manages the MIME encoding of the form, with a total of three values to choose from:

    • application/x-www-form-urlencoded (default value)

    • Multipart/form-data

    • Text/plain


①application/x-www-form-urlencoded is the default value, you may have seen this in Ajax: Xmlhttp.setrequestheader ("Content-type", "application/ X-www-form-urlencoded "); The two things to do is to set the encoding of the form transfer. It is possible to make an error in Ajax without writing, but the HTML form table dropdowns can not write enctype= "application/x-www-form-urlencoded" because the default HTML forms are the type of transmission encoding.

②multipart-form-data is used to specify the special type of transmission data, mainly the non-textual content we upload, compared to tablets or MP3 and so on.

Text/plain is the meaning of plain text transmission, in the sending of the message to set this type of encoding, or receive when the coding confusion , the network often take text/plain and text/html do compare, actually these two very good distinction, The former is used to transfer plain text files, while the latter is the encoding type for passing HTML code, which is used only when sending header files. ① and ③ cannot be used to upload files, only multipart/form-data can pass the file data intact.

Excerpt from:


Form form enctype= ' Multipart/form-data '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.