Why not always use enctype="multipart/form-data"?
Asked Answered
I

4

38

When building HTML forms why do we not always use enctype="multipart/form-data"?

Indiaindiaman answered 24/6, 2009 at 15:38 Comment(0)
P
32

multipart/form-data is a lot bulkier than application/x-www-form-urlencoded; the latter is just a bunch of keys and values (and can be parsed the same way whether for GET or POST), whereas the former requires full MIME support, and is thus more useful when you have data that can't simply be represented as key/value pairs.

Pumping answered 24/6, 2009 at 15:41 Comment(1)
We use enctype=“multipart/form-data” always since some months (even for forms without file uploads). It works nice. This makes our templates easier. One small step into the direction "conditionless". I did not do any byte counting since it does not matter in my context.Mcquiston
H
7

Because it's a pain to handle, both on the server and in custom clients. Simple is better than complicated, unless simple just doesn't work.

Hegumen answered 24/6, 2009 at 15:39 Comment(1)
I don't feel pain if the CPU is a little bit busy. Do you think this overhead is measurable?Mcquiston
L
1

With PHP it doesn't matter what kind o enctype the form had. You always get key/value pairs.

So if harder coding is the only reason not to and you are using PHP, just use enctype="multipart/form-data".

Is there any other reason?

Leland answered 6/2, 2010 at 19:17 Comment(2)
That's just PHP. There are more web programming languages in world than only PHP.Marnie
@BalusC: He said "and you are using PHP". Bruno wasn't talking about other web programming languages.Kneepad
I
0

Mulipart implicits that we are going to use different mime-types. For example, sending a binary file, you will have one part with the x-www-form-urlencoded part and the other with the octet-stream. Most of the times what you send is from the same mime type.

Inflect answered 4/9, 2010 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.