Why not always use enctype=“multipart/form-data”?

后端 未结 4 783
梦如初夏
梦如初夏 2020-12-13 13:11

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

相关标签:
4条回答
  • 2020-12-13 13:36

    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?

    0 讨论(0)
  • 2020-12-13 13:49

    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.

    0 讨论(0)
  • 2020-12-13 13:51

    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.

    0 讨论(0)
  • 2020-12-13 13:53

    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.

    0 讨论(0)
提交回复
热议问题