Is there a flaw in customizing the form for multipartication in HTML?

I am dynamically creating forms, and while I was displaying the form tag, I'm not sure if the form will have or will not have a file field. Is there a drawback to making these forms multi-part? Why don't we make all forms ubiquitous?

+4
source share
2 answers

As far as I know, there is no shortage. Maybe the / plain text might be a little easier in the transaction, but I don't think this is important. But for markup reasons, to keep the code clean, I would only use multipart when you really upload the file.

EDIT

I just did a test using a simple form and Fiddler , and the results:

-text/plain: 1,552 bytes sent -mulipart/form-data: 1,644 bytes sent 

In this case, the text / transparency in this case will be a little easier.

Now, if you have a larger form, the results are:

 -text/plain: 1,772 bytes sent -mulipart/form-data: 2,837 bytes sent 

Apparently, the difference will be higher as the size of the form increases.

I can’t say that it’s a big enough difference if you do everything you need to make your life easier.

+2
source

There are 3 possible enctype parameters (as indicated by W3Schools ):

  • text / plain Spaces are converted to "+" characters, but special characters are not encoded.
  • multipart / form-data strong> Characters are not encoded. This value is required if you are using forms that have a file upload control.
  • application / x-www-form-urlencoded . This is the default enctype. All characters are encoded before being sent (spaces are converted to "+" characters, and special characters are converted to ASCII HEX values)

Otherwise, there are no "failures", it simply determines how the form data will be sent to the server.

+1
source

Source: https://habr.com/ru/post/1391631/


All Articles