Performance with multipart / form-data

9

Regardless of the language used on the server side (php, asp, jsf, etc.), is there any problem in adding the enctype="multipart/form-data" attribute even on page forms that do not upload file? / p>

Because I use a template in an application and the form tag is in the template. As only a few pages upload, the attribute will appear on all pages, even those that do not upload.

    
asked by anonymous 25.11.2015 / 17:45

3 answers

4

According to this question in Stack Overflow , there are three values that you can pass in enctype:

  • application/x-www-form-urlencoded (default)
  • multipart/form-data
  • text/plain

The general rule is: if you are uploading files, use multipart/form-data ; otherwise, use application/x-www-form-urlencoded . Never use text/plain .

Answering your question: When you do not attach any type of file to your form, I think it's best to use multipart/form-data . This format uses fewer bytes than application/x-www-form-urlencoded . Therefore, server-side processing should also be smaller because it is handling a smaller string.

    
25.11.2015 / 18:22
4

The enctype attribute is responsible for defining how form data will be encoded when it is submitted, and also only works with POST .

There are currently 3 values that can be specified in this attribute:

  • application / x-www-form-urlencoded
  • multipart / form-data
  • text / plain

The application/x-www-form-urlencoded is the default value for enctype if none is specified, and if it is in use, all characters are encoded before they are sent.

If the multipart/form-data is set as the value for this attribute, no character is encoded. This type of request contains several parts, and each part of this request contains a content-diaposition with type form-data , and with an additional parameter name whose value is the name of the field.

Lastly, it has text/plain that converts spaces to + , but does not encode anything.

According to RFC-2388 Each part of a multipart/form-data must have a content type. In cases where the field is a text, the input character set indicates which encoding to use.

  

RFC-2388 - 4.5 -   For example, a form with a text field in which a user entered Joe must    100 ", where is the euro symbol can have form data returned As:

--AaB03x
content-disposition: form-data; name="field1"
content-type: text/plain;charset=windows-1250
content-transfer-encoding: quoted-printable

RFC-2388 - 5.2 - The multipart/form-data encoding has high overhead and some performance impacts if there are too many fields with few values. But in practice this overhead is not significant. If you really want more details, or are not clear enough, you will need to read this and some of the other RFCs for a better analysis of the gains and losses. Another good source would be here from w3.

    
25.11.2015 / 23:14
-3

When you are making a form, you must specify the type of file you want to upload.

By default, it is used:

enctype="multipart/form-data"
    
19.07.2018 / 15:43