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

As a result of the change, I found that admin django interfaces are enctype="multipart/form-data"always used .

I would like to accept this template, but I'm not sure if I see all its consequences.

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

+4
source share
4 answers

From the RFC , which defines multipart/form-data:

Many web applications use the "application / x-www-form-urlencoded" method to return data from forms. This format is quite compact, for example:

name=Xavier+Xantico&verdict=Yes&colour=Blue&happy=sad&Utf%F6r=Send

However, it is not possible to mark the attached data using the content type, apply encoding, or use other encoding mechanisms.

( -) multipart/form-data, "application/x-www-form-urlencoded".

, multipart/form-data . , , :

  • ( , , ).

  • , , application/x-www-form-urlencoded, -, ASCII.

+3

multipart/form-data . .

(x-www-form-urlencoded)

Content-Type: application/x-www-form-urlencoded; charset=utf-8

name=Nomen+Nescio&email=foo%40bar.com

/-

Content-Type: multipart/form-data; boundary=96a188ad5f9d4026822dacbdde47f43f

--96a188ad5f9d4026822dacbdde47f43f
Content-Disposition: form-data; name="name"

Nomen Nescio
--96a188ad5f9d4026822dacbdde47f43f
Content-Disposition: form-data; name="email"

foo@bar.com
--96a188ad5f9d4026822dacbdde47f43f

, (37 252 )

http , .

urlencoded over multipart http.

+5

TL; DR

, SSL .

form-data , rfc 1867. , HTML 4.x , , enc-type, . , .

, , , 20 .

, . , , , , HTML. , , , , , , HTTPS .

+2

The attribute enctypedefines how the form data should be encoded when sent to the server, and enctype="multipart/form-data"used when the user wants to upload a file (images, text files, etc.) to the server.

0
source

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


All Articles