Form Properties Enctype= "Multipart/form-data"

Source: Internet
Author: User

The first thing to know is that the Enctype property manages the MIME encoding of the form. A total of three values are optional:
1, application/x-www-form-urlencoded
2, Multipart/form-data
3, Text/plain
Where application/x-www-form-urlencoded is the default value, the function is to set the encoding of the form transfer. For example, we have seen Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded") 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.
And Multipart/form-data is used to develop a special type of transmission data, mainly we upload non-text content, than tablets or MP3 and so on.
Text/plain is the meaning of plain text transmission, in the e-mail to set this type of encoding, otherwise there will be the problem of encoding confusion when receiving. Network often take text/plain and text/html to do comparison, in fact, these two very good distinction, the former is used to transfer plain text files, the latter is the transmission of HTML code encoding type, in the sending of the header file is used. ① and ③ cannot be used to upload files, only multipart/form-data can pass file data in full.

The above mentioned MIME, its full name is "Multipurpose Internet Mail Extensions" Multi-functional Internet Message expansion service, it is a multi-purpose Internet Mail Expansion protocol, in 1992, the earliest application of the e-mail system, But later also applied to the browser. The server will tell the browser the type of multimedia data that they send, and the notification means that it describes the MIME type of the multimedia data, allowing the browser to know what the MP3 file is, which is the shockwave file, and so on. The server puts the MIME marker in the transferred data to tell the browser which plug-in to use to read the relevant file.

Simply put, the MIME type is the type of file that is set up with an extension that is opened by an application, and the browser automatically opens with the specified application when the extension file is accessed. Many are used to specify some client-customized file names, as well as some ways to open media files.

After the browser receives the file, it will go to the plug-in system to find out which plug-in can recognize the read received file. If the browser does not know which plug-in system to call, it may tell the user that a plugin is missing, or directly select an existing plug-in to attempt to read the received file, which may cause a system 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.

The steps to check if a server is setting the MIME type correctly are:

1. Open the Server Web page in the Netscape browser

2. Go to the "View" menu and select "Page Info"

3. In the pop-up window, click "EMBED" in the upper frame.

4. In the lower frame, see if the MIME type is "Application/x-director" or "Application/x-shockwave-flash", and if this is the case, the server has set the MIME type correctly , and if the MIME type lists text content, eight-bit data, or any other form, it indicates that the MIME type of the server is not set correctly.

If the server does not correctly indicate the type of data it sends, the server administrator should add the relevant information correctly, and the method of operation is very simple and quick.

Each MIME type consists of two parts, preceded by a large category of data, such as audio audio, image image, and so on, followed by a specific category.

Common MIME Types

Hypertext Markup Language text. html,.html text/html

Plain text. txt Text/plain

RTF text. rtf Application/rtf

GIF graphics. gif image/gif

JPEG graphics. Jpeg,.jpg Image/jpeg

Au sound file. Au audio/basic

Midi Music files Mid,.midi Audio/midi,audio/x-midi

RealAudio music files. RA,. Ram Audio/x-pn-realaudio

MPEG files. Mpg,.mpeg video/mpeg

AVI file. avi Video/x-msvideo

gzip file. GZ application/x-gzip

Tar file. Tar Application/x-tar

The Internet has a special organization IANA to confirm the standard MIME type, but the internet is growing too fast, and many applications can't wait for the IANA to confirm that they use the MIME type as the standard type. So they use a method that begins with X in the category to identify that the category has not yet become a standard, such as X-gzip,x-tar. In fact, these types are widely used and have become the standard of fact. As long as both the client and the server recognize this MIME type, even if it is not a standard type, the client program can handle the data according to the MIME type using specific processing methods. Both the standard and common MIME types are set by default in Web servers and browsers (including operating systems), and only for uncommon MIME types, you need to set up both the server and the client browser for identification purposes.
----------------------------------------------------------------
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 and cannot be used for file uploads;
Only use Multipart/form-data to complete the transfer of file data, the following operation. Enctype= "Multipart/form-data" is to upload binary data; The value of input in the form is passed in 2 binary ways.
The value of input in the form is passed in 2 binary ways,
So the request is not worth the value. That is, add this code, with the request will be passed unsuccessful, take the form value added to the database, use the following:

Smartupload su = new smartupload ();//Create a new Smartupload object

Su.getrequest (). Getparametervalues (); Take array values

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

Form Properties 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: 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.