Students Empire

Learn Something New

form encoding

The enctype attribute specifies how the browser encodes and presents the data to the server.

  • application/x-www-form-urlencoded - Default encoding. This encoding cannot be used to upload files to the server.
  • multipart/form-data - This encoding is used to upload files to the server.
  • text/plain - This encoding varies between browsers.

                  <!DOCTYPE HTML>
              <form method="post" action="">
              <input name="fave">
              <input name="name">


If using application/x-www-form-urlencoded encoding

The name and value of each data item is encoded using the same scheme that is used to encode URLs. This is how the encoding is applied to the data in the example form:


Special characters are replaced with their HTML entity counterpart. The name of the data item and the value are separated by the equals sign (=) and data/value tuples are separated by the ampersand character (&).


The multipart/form-data encoding tends to be used only for uploading files. Here is how the data from the example form is encoded:


                  Content-Disposition: form-data; name="fave" YourName
                  ------WebKitFormBoundary2desQWER543CDFGF Content-Disposition: form-data; name="name"


The mainstream browsers encode data in different ways for this encoding.

Google Chrome encodes data in the same way as for the application/x-www-form-urlencoded scheme, whereas Firefox encodes the data as follows:


Each data item is placed on a line, and special characters are not encoded.