Sets the encoding format for form form transfer application/x-www-form-urlencoded, Multipart/form-data, Text/plain__java

Source: Internet
Author: User
Tags html form

--------------------------------------------------------------------------------------
The meaning of enctype= "Multipart/form-data" in the form is to set the MIME encoding of the form. (for file upload)

By default, this encoding format is application/x-www-form-urlencoded (not for file uploads);


Only Multipart/form-data can be used to complete the transfer of file data.


Enctype= "Multipart/form-data" is the uploading of binary data; The input value in the form is in 2.

The way the system passed.

The value of the input in the form is passed in the form of 2,


So the request is not worth it. In other words, the code is added, and the request will pass unsuccessful


When you add a form value to a database, you use the following:

Smartupload su = new smartupload ()//New Smartupload Object

Su.getrequest (). Getparametervalues (); take the array value

Su.getrequest (). GetParameter (); Take a single parameter single value

------------------------------------------------------------------------------------------------------

Upload files in the form of <form> to add attributes Enctype= "Multipart/form-data",

In fact, form forms when you do not write the enctype attribute, the default is to add the Enctype property value, the default value 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

Where ①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 not possible to write an error in Ajax, but in HTML form table dropdowns can not write enctype= "application/x-www-form-urlencoded" because the default HTML form is this type of transmission encoding.


②multipart-form-data is a special type of data that is used to specify the transmission, mainly the text that we upload, such as pictures or MP3, etc.


③text/plain is the meaning of pure text transmission, when sending mail to set this type of encoding, otherwise there will be the problem of coding confusion, the network often take text/plain and text/html do comparisons, in fact, these two very good distinction, the former used to transfer plain text files, The latter is the encoding type that passes the HTML code,


The

is only used when sending header files. ① and ③ can not be used to upload files, only multipart/form-data can complete the transfer of file data. The MIME, referred to in

, is the full name of the "Multipurpose Internet Mail Extensions" Multipurpose Internet Mail Extension Service, a Multipurpose Internet Mail Extension Protocol, It was first applied to the e-mail system in 1992, but it was later applied to the browser. The server tells the browser the type of multimedia data they send, and the notification means the MIME type of the multimedia data to let the browser know which information is MP3 and which are Shockwave files and so on. The server puts the MIME markers in the transferred data to tell the browser which plug-in to use to read the related files.

Simply put, the MIME type is the type of way in which a file with an extension is set to open in an application, and when the file is accessed, the browser automatically opens with the specified application. Used to specify some client-defined file names and how some media files are opened. When a file is received by the

Browser, it enters the plug-in system to find out which plug-ins can recognize the files received by the read. If the browser does not know which plug-in system to call, it may tell the user that a plugin is missing, or that an existing plug-in may be selected directly to attempt to read the received file, which could cause the system to crash. The lack of a MIME identity in the transmitted information can be difficult to estimate because some computer systems may not fail, but some computers may crash as a result.

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: info-contact@alibabacloud.com 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.