What does enctype='multipart/form-data' mean?











up vote
1091
down vote

favorite
410












What does enctype='multipart/form-data' mean in an HTML form and when should we use it?










share|improve this question
























  • w3.org/html/wg/spec/…
    – JohnOsborne
    Aug 9 at 10:26















up vote
1091
down vote

favorite
410












What does enctype='multipart/form-data' mean in an HTML form and when should we use it?










share|improve this question
























  • w3.org/html/wg/spec/…
    – JohnOsborne
    Aug 9 at 10:26













up vote
1091
down vote

favorite
410









up vote
1091
down vote

favorite
410






410





What does enctype='multipart/form-data' mean in an HTML form and when should we use it?










share|improve this question















What does enctype='multipart/form-data' mean in an HTML form and when should we use it?







html http-headers multipartform-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 23:50









naXa

13.1k885132




13.1k885132










asked Dec 24 '10 at 12:19









EBAG

6,87494584




6,87494584












  • w3.org/html/wg/spec/…
    – JohnOsborne
    Aug 9 at 10:26


















  • w3.org/html/wg/spec/…
    – JohnOsborne
    Aug 9 at 10:26
















w3.org/html/wg/spec/…
– JohnOsborne
Aug 9 at 10:26




w3.org/html/wg/spec/…
– JohnOsborne
Aug 9 at 10:26












9 Answers
9






active

oldest

votes

















up vote
1227
down vote



accepted










When you make a POST request, you have to encode the data that forms the body of the request in some way.



HTML forms provide three methods of encoding.





  • application/x-www-form-urlencoded (the default)

  • multipart/form-data

  • text/plain


Work was being done on adding application/json, but that has been abandoned.



The specifics of the formats don't matter to most developers. The important points are:



When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.



When you are writing server-side code: Use a prewritten form handling library (e.g. Perl's CGI->param or the one exposed by PHP's $_POST superglobal) and it will take care of the differences for you. Don't bother trying to parse the raw input received by the server.



Never use text/plain.





If you are writing (or debugging) a library for parsing or generating the raw data, then you need to start worrying about the format. You might also want to know about it for interest's sake.



application/x-www-form-urlencoded is more or less the same as a query string on the end of the URL.



multipart/form-data is significantly more complicated but it allows entire files to be included in the data. An example of the result can be found in the HTML 4 specification.



text/plain is introduced by HTML 5 and is useful only for debugging — from the spec: They are not reliably interpretable by computer — and I'd argue that the others combined with tools (like the Net tab in the developer tools of most browsers) are better for that).






share|improve this answer



















  • 4




    @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
    – Royi Namir
    Sep 15 '13 at 10:10








  • 8




    Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
    – Quentin
    Sep 15 '13 at 10:18








  • 4




    @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
    – Webinan
    Oct 20 '13 at 9:47






  • 8




    It doesn't make sense for GET forms, and it makes the file size of requests bigger.
    – Quentin
    Oct 20 '13 at 10:46






  • 5




    @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
    – Devrath
    Nov 22 '13 at 9:05


















up vote
332
down vote














when should we use it




Quentin's answer is right: use multipart/form-data if the form contains a file upload, and application/x-www-form-urlencoded otherwise, which is the default if you omit enctype.



I'm going to:




  • add some more HTML5 references

  • explain why he is right with a form submit example


HTML5 references



There are three possibilities for enctype:




  • x-www-urlencoded


  • multipart/form-data (spec points to RFC7578)


  • text-plain. This is "not reliably interpretable by computer", so it should never be used in production, and we will not look further into it.


How to generate the examples



Once you see an example of each method, it becomes obvious how they work, and when you should use each one.



You can produce examples using:





  • nc -l or an ECHO server: HTTP test server accepting GET/POST requests

  • an user agent like a browser or cURL


Save the form to a minimal .html file:



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>upload</title>
</head>
<body>
<form action="http://localhost:8000" method="post" enctype="multipart/form-data">
<p><input type="text" name="text1" value="text default">
<p><input type="text" name="text2" value="aωb">
<p><input type="file" name="file1">
<p><input type="file" name="file2">
<p><input type="file" name="file3">
<p><button type="submit">Submit</button>
</form>
</body>
</html>


We set the default text value to aωb, which means aωb because ω is U+03C9, which are the bytes 61 CF 89 62 in UTF-8.



Create files to upload:



echo 'Content of a.txt.' > a.txt

echo '<!DOCTYPE html><title>Content of a.html.</title>' > a.html

# Binary file containing 4 bytes: 'a', 1, 2 and 'b'.
printf 'axCFx89b' > binary


Run our little echo server:



while true; do printf '' | nc -l 8000 localhost; done


Open the HTML on your browser, select the files and click on submit and check the terminal.



nc prints the request received.



Tested on: Ubuntu 14.04.3, nc BSD 1.105, Firefox 40.



multipart/form-data



Firefox sent:



POST / HTTP/1.1
[[ Less interesting headers ... ]]
Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
Content-Length: 834

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text1"

text default
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text2"

aωb
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain

Content of a.txt.

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html

<!DOCTYPE html><title>Content of a.html.</title>

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file3"; filename="binary"
Content-Type: application/octet-stream

aωb
-----------------------------735323031399963166993862150--


For the binary file and text field, the bytes 61 CF 89 62 (aωb in UTF-8) are sent literally. You could verify that with nc -l localhost 8000 | hd, which says that the bytes:



61 CF 89 62


were sent (61 == 'a' and 62 == 'b').



Therefore it is clear that:




  • Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 sets the content type to multipart/form-data and says that the fields are separated by the given boundary string.



  • every field gets some sub headers before its data: Content-Disposition: form-data;, the field name, the filename, followed by the data.



    The server reads the data until the next boundary string. The browser must choose a boundary that will not appear in any of the fields, so this is why the boundary may vary between requests.



    Because we have the unique boundary, no encoding of the data is necessary: binary data is sent as is.



    TODO: what is the optimal boundary size (log(N) I bet), and name / running time of the algorithm that finds it? Asked at: https://cs.stackexchange.com/questions/39687/find-the-shortest-sequence-that-is-not-a-sub-sequence-of-a-set-of-sequences




  • Content-Type is automatically determined by the browser.



    How it is determined exactly was asked at: How is mime type of an uploaded file determined by browser?




application/x-www-form-urlencoded



Now change the enctype to application/x-www-form-urlencoded, reload the browser, and resubmit.



Firefox sent:



POST / HTTP/1.1
[[ Less interesting headers ... ]]
Content-Type: application/x-www-form-urlencoded
Content-Length: 51

text1=text+default&text2=a%CF%89b&file1=a.txt&file2=a.html&file3=binary


Clearly the file data was not sent, only the basenames. So this cannot be used for files.



As for the text field, we see that usual printable characters like a and b were sent in one byte, while non-printable ones like 0xCF and 0x89 took up 3 bytes each: %CF%89!



Comparison



File uploads often contain lots of non-printable characters (e.g. images), while text forms almost never do.



From the examples we have seen that:




  • multipart/form-data: adds a few bytes of boundary overhead to the message, and must spend some time calculating it, but sends each byte in one byte.


  • application/x-www-form-urlencoded: has a single byte boundary per field (&), but adds a linear overhead factor of 3x for every non-printable character.



Therefore, even if we could send files with application/x-www-form-urlencoded, we wouldn't want to, because it is so inefficient.



But for printable characters found in text fields, it does not matter and generates less overhead, so we just use it.






share|improve this answer























  • Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
    – Khanna111
    Aug 6 '15 at 18:42






  • 2




    @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Aug 6 '15 at 18:50






  • 4




    This should be the actual answer.
    – Ramazan Polat
    Nov 6 '16 at 5:41






  • 5




    On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
    – PhilipS
    Apr 25 '17 at 2:03








  • 2




    A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
    – Bernard
    Jul 3 '17 at 12:34


















up vote
76
down vote













enctype='multipart/form-data is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.



If you want to allow a user to upload a file via a form, you must use this enctype.






share|improve this answer























  • So.. if the file is not a binary file then can we work without this ?
    – Yugal Jindle
    Aug 27 '13 at 0:01










  • From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
    – Matt Asbury
    Aug 27 '13 at 9:36








  • 8




    The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
    – Daniel Luna
    Sep 19 '13 at 17:34






  • 5




    Its worth pointing out you can base64 encode your image and send it as plain string data .
    – Prospero
    Jul 14 '14 at 22:46


















up vote
69
down vote













When submitting a form, you're trying to say your browser to send via the HTTP protocol a message on the network properly enveloped in a TCP/IP protocol message structure. When sending data, you can use POST or GET methods to send data using HTTP protocol. POST tells your browser to build an HTTP message and put all content in the body of the message (a very useful way of doing things, more safe and also flexible). GET has some constraints about data representation and length.



Stating what you send



When sending a file, it is necessary to tell the HTTP protocol that you are sending a file having several characteristics and information inside it. In this way it is possible to consistently send data to receiver and let it open the file with the current format and so on...
This is a requirement from the HTTP protocol as shown here



You cannot send files using default enctype parameters because your receiver might encounter problems reading it (consider that a file is a descriptor for some data for a specific operating system, if you see things this way, maybe you'll understand why it is so important to specify a different enctype for files).



Do not forget security



This way of doing things also ensures that some security algorithms work on your messages. This information is also used by application-level routers in order to act as good firewalls for external data.



Well, as you can see, it is not a stupid thing using a specific enctype for files.






share|improve this answer



















  • 5




    header of the message or body of the message?
    – manikanta
    Apr 4 '13 at 12:52






  • 1




    The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
    – Andry
    Apr 4 '13 at 21:13










  • I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
    – Jondlm
    Nov 8 '13 at 6:13










  • Hi All! yes you are all right, I fixed the answer already some time ago...
    – Andry
    Sep 17 '17 at 18:50


















up vote
29
down vote













enctype='multipart/form-data' means that no characters will be encoded. that is why this type is used while uploading files to server.

So multipart/form-data is used when a form requires binary data, like the contents of a file, to be uploaded






share|improve this answer






























    up vote
    9
    down vote













    Set the method attribute to POST because file content can't be put inside a URL parameter using a form.



    Set the value of enctype to multipart/form-data because the data will be split into multiple parts, one for each file plus one for the text of the form body that may be sent with them.






    share|improve this answer





















    • This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
      – underscore_d
      Jun 11 '17 at 12:33


















    up vote
    1
    down vote













    Usually this is when you have a POST form which needs to take a file upload as data... this will tell the server how it will encode the data transferred, in such case it won't get encoded because it will just transfer and upload the files to the server, Like for example when uploading an image or a pdf






    share|improve this answer




























      up vote
      1
      down vote














      • enctype(ENCode TYPE) attribute specifies how the form-data should be encoded when submitting it to the server.


      • multipart/form-data is one of the value of enctype attribute, which is used in form element that have a file upload. multi-part means form data divides into multiple parts and send to server.


        • metaphor part : an HTML document has two parts: a head and a body.








      share|improve this answer



















      • 4




        I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
        – Yeo
        Mar 3 '16 at 11:00




















      up vote
      1
      down vote














      The enctype attribute specifies how the form-data should be encoded when submitting it to the server.



      The enctype attribute can be used only if method="post".



      No characters are encoded. This value is required when you are using forms that have a file upload control




      From W3Schools






      share|improve this answer






















        protected by NINCOMPOOP Nov 4 '13 at 7:17



        Thank you for your interest in this question.
        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



        Would you like to answer one of these unanswered questions instead?














        9 Answers
        9






        active

        oldest

        votes








        9 Answers
        9






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1227
        down vote



        accepted










        When you make a POST request, you have to encode the data that forms the body of the request in some way.



        HTML forms provide three methods of encoding.





        • application/x-www-form-urlencoded (the default)

        • multipart/form-data

        • text/plain


        Work was being done on adding application/json, but that has been abandoned.



        The specifics of the formats don't matter to most developers. The important points are:



        When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.



        When you are writing server-side code: Use a prewritten form handling library (e.g. Perl's CGI->param or the one exposed by PHP's $_POST superglobal) and it will take care of the differences for you. Don't bother trying to parse the raw input received by the server.



        Never use text/plain.





        If you are writing (or debugging) a library for parsing or generating the raw data, then you need to start worrying about the format. You might also want to know about it for interest's sake.



        application/x-www-form-urlencoded is more or less the same as a query string on the end of the URL.



        multipart/form-data is significantly more complicated but it allows entire files to be included in the data. An example of the result can be found in the HTML 4 specification.



        text/plain is introduced by HTML 5 and is useful only for debugging — from the spec: They are not reliably interpretable by computer — and I'd argue that the others combined with tools (like the Net tab in the developer tools of most browsers) are better for that).






        share|improve this answer



















        • 4




          @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
          – Royi Namir
          Sep 15 '13 at 10:10








        • 8




          Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
          – Quentin
          Sep 15 '13 at 10:18








        • 4




          @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
          – Webinan
          Oct 20 '13 at 9:47






        • 8




          It doesn't make sense for GET forms, and it makes the file size of requests bigger.
          – Quentin
          Oct 20 '13 at 10:46






        • 5




          @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
          – Devrath
          Nov 22 '13 at 9:05















        up vote
        1227
        down vote



        accepted










        When you make a POST request, you have to encode the data that forms the body of the request in some way.



        HTML forms provide three methods of encoding.





        • application/x-www-form-urlencoded (the default)

        • multipart/form-data

        • text/plain


        Work was being done on adding application/json, but that has been abandoned.



        The specifics of the formats don't matter to most developers. The important points are:



        When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.



        When you are writing server-side code: Use a prewritten form handling library (e.g. Perl's CGI->param or the one exposed by PHP's $_POST superglobal) and it will take care of the differences for you. Don't bother trying to parse the raw input received by the server.



        Never use text/plain.





        If you are writing (or debugging) a library for parsing or generating the raw data, then you need to start worrying about the format. You might also want to know about it for interest's sake.



        application/x-www-form-urlencoded is more or less the same as a query string on the end of the URL.



        multipart/form-data is significantly more complicated but it allows entire files to be included in the data. An example of the result can be found in the HTML 4 specification.



        text/plain is introduced by HTML 5 and is useful only for debugging — from the spec: They are not reliably interpretable by computer — and I'd argue that the others combined with tools (like the Net tab in the developer tools of most browsers) are better for that).






        share|improve this answer



















        • 4




          @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
          – Royi Namir
          Sep 15 '13 at 10:10








        • 8




          Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
          – Quentin
          Sep 15 '13 at 10:18








        • 4




          @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
          – Webinan
          Oct 20 '13 at 9:47






        • 8




          It doesn't make sense for GET forms, and it makes the file size of requests bigger.
          – Quentin
          Oct 20 '13 at 10:46






        • 5




          @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
          – Devrath
          Nov 22 '13 at 9:05













        up vote
        1227
        down vote



        accepted







        up vote
        1227
        down vote



        accepted






        When you make a POST request, you have to encode the data that forms the body of the request in some way.



        HTML forms provide three methods of encoding.





        • application/x-www-form-urlencoded (the default)

        • multipart/form-data

        • text/plain


        Work was being done on adding application/json, but that has been abandoned.



        The specifics of the formats don't matter to most developers. The important points are:



        When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.



        When you are writing server-side code: Use a prewritten form handling library (e.g. Perl's CGI->param or the one exposed by PHP's $_POST superglobal) and it will take care of the differences for you. Don't bother trying to parse the raw input received by the server.



        Never use text/plain.





        If you are writing (or debugging) a library for parsing or generating the raw data, then you need to start worrying about the format. You might also want to know about it for interest's sake.



        application/x-www-form-urlencoded is more or less the same as a query string on the end of the URL.



        multipart/form-data is significantly more complicated but it allows entire files to be included in the data. An example of the result can be found in the HTML 4 specification.



        text/plain is introduced by HTML 5 and is useful only for debugging — from the spec: They are not reliably interpretable by computer — and I'd argue that the others combined with tools (like the Net tab in the developer tools of most browsers) are better for that).






        share|improve this answer














        When you make a POST request, you have to encode the data that forms the body of the request in some way.



        HTML forms provide three methods of encoding.





        • application/x-www-form-urlencoded (the default)

        • multipart/form-data

        • text/plain


        Work was being done on adding application/json, but that has been abandoned.



        The specifics of the formats don't matter to most developers. The important points are:



        When you are writing client-side code, all you need to know is use multipart/form-data when your form includes any <input type="file"> elements.



        When you are writing server-side code: Use a prewritten form handling library (e.g. Perl's CGI->param or the one exposed by PHP's $_POST superglobal) and it will take care of the differences for you. Don't bother trying to parse the raw input received by the server.



        Never use text/plain.





        If you are writing (or debugging) a library for parsing or generating the raw data, then you need to start worrying about the format. You might also want to know about it for interest's sake.



        application/x-www-form-urlencoded is more or less the same as a query string on the end of the URL.



        multipart/form-data is significantly more complicated but it allows entire files to be included in the data. An example of the result can be found in the HTML 4 specification.



        text/plain is introduced by HTML 5 and is useful only for debugging — from the spec: They are not reliably interpretable by computer — and I'd argue that the others combined with tools (like the Net tab in the developer tools of most browsers) are better for that).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 15 '15 at 8:35

























        answered Dec 24 '10 at 12:21









        Quentin

        638k718611031




        638k718611031








        • 4




          @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
          – Royi Namir
          Sep 15 '13 at 10:10








        • 8




          Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
          – Quentin
          Sep 15 '13 at 10:18








        • 4




          @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
          – Webinan
          Oct 20 '13 at 9:47






        • 8




          It doesn't make sense for GET forms, and it makes the file size of requests bigger.
          – Quentin
          Oct 20 '13 at 10:46






        • 5




          @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
          – Devrath
          Nov 22 '13 at 9:05














        • 4




          @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
          – Royi Namir
          Sep 15 '13 at 10:10








        • 8




          Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
          – Quentin
          Sep 15 '13 at 10:18








        • 4




          @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
          – Webinan
          Oct 20 '13 at 9:47






        • 8




          It doesn't make sense for GET forms, and it makes the file size of requests bigger.
          – Quentin
          Oct 20 '13 at 10:46






        • 5




          @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
          – Devrath
          Nov 22 '13 at 9:05








        4




        4




        @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
        – Royi Namir
        Sep 15 '13 at 10:10






        @Quentin What If I have a form which upload files and also has textArea. Will the whole form will submit as Binary (multipart) ? Is it a valid situation ? or should I have multiple forms...
        – Royi Namir
        Sep 15 '13 at 10:10






        8




        8




        Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
        – Quentin
        Sep 15 '13 at 10:18






        Multipart is no more binary than any other encoding. Multipart does not prevent you from using non-file inputs. Having multiple forms would be stupid.
        – Quentin
        Sep 15 '13 at 10:18






        4




        4




        @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
        – Webinan
        Oct 20 '13 at 9:47




        @Quentin Excuse me, what will be any probable problem if we use multipart for all forms? with and whit out files.
        – Webinan
        Oct 20 '13 at 9:47




        8




        8




        It doesn't make sense for GET forms, and it makes the file size of requests bigger.
        – Quentin
        Oct 20 '13 at 10:46




        It doesn't make sense for GET forms, and it makes the file size of requests bigger.
        – Quentin
        Oct 20 '13 at 10:46




        5




        5




        @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
        – Devrath
        Nov 22 '13 at 9:05




        @ Quentin ..... [+1] FOR GREAT ANSWER .... can you point a web source .... that shows the structure of multipart/form-data ..... espically when a string with an image is involved ..... Thanks !
        – Devrath
        Nov 22 '13 at 9:05












        up vote
        332
        down vote














        when should we use it




        Quentin's answer is right: use multipart/form-data if the form contains a file upload, and application/x-www-form-urlencoded otherwise, which is the default if you omit enctype.



        I'm going to:




        • add some more HTML5 references

        • explain why he is right with a form submit example


        HTML5 references



        There are three possibilities for enctype:




        • x-www-urlencoded


        • multipart/form-data (spec points to RFC7578)


        • text-plain. This is "not reliably interpretable by computer", so it should never be used in production, and we will not look further into it.


        How to generate the examples



        Once you see an example of each method, it becomes obvious how they work, and when you should use each one.



        You can produce examples using:





        • nc -l or an ECHO server: HTTP test server accepting GET/POST requests

        • an user agent like a browser or cURL


        Save the form to a minimal .html file:



        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="utf-8"/>
        <title>upload</title>
        </head>
        <body>
        <form action="http://localhost:8000" method="post" enctype="multipart/form-data">
        <p><input type="text" name="text1" value="text default">
        <p><input type="text" name="text2" value="aωb">
        <p><input type="file" name="file1">
        <p><input type="file" name="file2">
        <p><input type="file" name="file3">
        <p><button type="submit">Submit</button>
        </form>
        </body>
        </html>


        We set the default text value to aωb, which means aωb because ω is U+03C9, which are the bytes 61 CF 89 62 in UTF-8.



        Create files to upload:



        echo 'Content of a.txt.' > a.txt

        echo '<!DOCTYPE html><title>Content of a.html.</title>' > a.html

        # Binary file containing 4 bytes: 'a', 1, 2 and 'b'.
        printf 'axCFx89b' > binary


        Run our little echo server:



        while true; do printf '' | nc -l 8000 localhost; done


        Open the HTML on your browser, select the files and click on submit and check the terminal.



        nc prints the request received.



        Tested on: Ubuntu 14.04.3, nc BSD 1.105, Firefox 40.



        multipart/form-data



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
        Content-Length: 834

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text1"

        text default
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text2"

        aωb
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file1"; filename="a.txt"
        Content-Type: text/plain

        Content of a.txt.

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file2"; filename="a.html"
        Content-Type: text/html

        <!DOCTYPE html><title>Content of a.html.</title>

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file3"; filename="binary"
        Content-Type: application/octet-stream

        aωb
        -----------------------------735323031399963166993862150--


        For the binary file and text field, the bytes 61 CF 89 62 (aωb in UTF-8) are sent literally. You could verify that with nc -l localhost 8000 | hd, which says that the bytes:



        61 CF 89 62


        were sent (61 == 'a' and 62 == 'b').



        Therefore it is clear that:




        • Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 sets the content type to multipart/form-data and says that the fields are separated by the given boundary string.



        • every field gets some sub headers before its data: Content-Disposition: form-data;, the field name, the filename, followed by the data.



          The server reads the data until the next boundary string. The browser must choose a boundary that will not appear in any of the fields, so this is why the boundary may vary between requests.



          Because we have the unique boundary, no encoding of the data is necessary: binary data is sent as is.



          TODO: what is the optimal boundary size (log(N) I bet), and name / running time of the algorithm that finds it? Asked at: https://cs.stackexchange.com/questions/39687/find-the-shortest-sequence-that-is-not-a-sub-sequence-of-a-set-of-sequences




        • Content-Type is automatically determined by the browser.



          How it is determined exactly was asked at: How is mime type of an uploaded file determined by browser?




        application/x-www-form-urlencoded



        Now change the enctype to application/x-www-form-urlencoded, reload the browser, and resubmit.



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: application/x-www-form-urlencoded
        Content-Length: 51

        text1=text+default&text2=a%CF%89b&file1=a.txt&file2=a.html&file3=binary


        Clearly the file data was not sent, only the basenames. So this cannot be used for files.



        As for the text field, we see that usual printable characters like a and b were sent in one byte, while non-printable ones like 0xCF and 0x89 took up 3 bytes each: %CF%89!



        Comparison



        File uploads often contain lots of non-printable characters (e.g. images), while text forms almost never do.



        From the examples we have seen that:




        • multipart/form-data: adds a few bytes of boundary overhead to the message, and must spend some time calculating it, but sends each byte in one byte.


        • application/x-www-form-urlencoded: has a single byte boundary per field (&), but adds a linear overhead factor of 3x for every non-printable character.



        Therefore, even if we could send files with application/x-www-form-urlencoded, we wouldn't want to, because it is so inefficient.



        But for printable characters found in text fields, it does not matter and generates less overhead, so we just use it.






        share|improve this answer























        • Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
          – Khanna111
          Aug 6 '15 at 18:42






        • 2




          @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Aug 6 '15 at 18:50






        • 4




          This should be the actual answer.
          – Ramazan Polat
          Nov 6 '16 at 5:41






        • 5




          On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
          – PhilipS
          Apr 25 '17 at 2:03








        • 2




          A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
          – Bernard
          Jul 3 '17 at 12:34















        up vote
        332
        down vote














        when should we use it




        Quentin's answer is right: use multipart/form-data if the form contains a file upload, and application/x-www-form-urlencoded otherwise, which is the default if you omit enctype.



        I'm going to:




        • add some more HTML5 references

        • explain why he is right with a form submit example


        HTML5 references



        There are three possibilities for enctype:




        • x-www-urlencoded


        • multipart/form-data (spec points to RFC7578)


        • text-plain. This is "not reliably interpretable by computer", so it should never be used in production, and we will not look further into it.


        How to generate the examples



        Once you see an example of each method, it becomes obvious how they work, and when you should use each one.



        You can produce examples using:





        • nc -l or an ECHO server: HTTP test server accepting GET/POST requests

        • an user agent like a browser or cURL


        Save the form to a minimal .html file:



        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="utf-8"/>
        <title>upload</title>
        </head>
        <body>
        <form action="http://localhost:8000" method="post" enctype="multipart/form-data">
        <p><input type="text" name="text1" value="text default">
        <p><input type="text" name="text2" value="aωb">
        <p><input type="file" name="file1">
        <p><input type="file" name="file2">
        <p><input type="file" name="file3">
        <p><button type="submit">Submit</button>
        </form>
        </body>
        </html>


        We set the default text value to aωb, which means aωb because ω is U+03C9, which are the bytes 61 CF 89 62 in UTF-8.



        Create files to upload:



        echo 'Content of a.txt.' > a.txt

        echo '<!DOCTYPE html><title>Content of a.html.</title>' > a.html

        # Binary file containing 4 bytes: 'a', 1, 2 and 'b'.
        printf 'axCFx89b' > binary


        Run our little echo server:



        while true; do printf '' | nc -l 8000 localhost; done


        Open the HTML on your browser, select the files and click on submit and check the terminal.



        nc prints the request received.



        Tested on: Ubuntu 14.04.3, nc BSD 1.105, Firefox 40.



        multipart/form-data



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
        Content-Length: 834

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text1"

        text default
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text2"

        aωb
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file1"; filename="a.txt"
        Content-Type: text/plain

        Content of a.txt.

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file2"; filename="a.html"
        Content-Type: text/html

        <!DOCTYPE html><title>Content of a.html.</title>

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file3"; filename="binary"
        Content-Type: application/octet-stream

        aωb
        -----------------------------735323031399963166993862150--


        For the binary file and text field, the bytes 61 CF 89 62 (aωb in UTF-8) are sent literally. You could verify that with nc -l localhost 8000 | hd, which says that the bytes:



        61 CF 89 62


        were sent (61 == 'a' and 62 == 'b').



        Therefore it is clear that:




        • Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 sets the content type to multipart/form-data and says that the fields are separated by the given boundary string.



        • every field gets some sub headers before its data: Content-Disposition: form-data;, the field name, the filename, followed by the data.



          The server reads the data until the next boundary string. The browser must choose a boundary that will not appear in any of the fields, so this is why the boundary may vary between requests.



          Because we have the unique boundary, no encoding of the data is necessary: binary data is sent as is.



          TODO: what is the optimal boundary size (log(N) I bet), and name / running time of the algorithm that finds it? Asked at: https://cs.stackexchange.com/questions/39687/find-the-shortest-sequence-that-is-not-a-sub-sequence-of-a-set-of-sequences




        • Content-Type is automatically determined by the browser.



          How it is determined exactly was asked at: How is mime type of an uploaded file determined by browser?




        application/x-www-form-urlencoded



        Now change the enctype to application/x-www-form-urlencoded, reload the browser, and resubmit.



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: application/x-www-form-urlencoded
        Content-Length: 51

        text1=text+default&text2=a%CF%89b&file1=a.txt&file2=a.html&file3=binary


        Clearly the file data was not sent, only the basenames. So this cannot be used for files.



        As for the text field, we see that usual printable characters like a and b were sent in one byte, while non-printable ones like 0xCF and 0x89 took up 3 bytes each: %CF%89!



        Comparison



        File uploads often contain lots of non-printable characters (e.g. images), while text forms almost never do.



        From the examples we have seen that:




        • multipart/form-data: adds a few bytes of boundary overhead to the message, and must spend some time calculating it, but sends each byte in one byte.


        • application/x-www-form-urlencoded: has a single byte boundary per field (&), but adds a linear overhead factor of 3x for every non-printable character.



        Therefore, even if we could send files with application/x-www-form-urlencoded, we wouldn't want to, because it is so inefficient.



        But for printable characters found in text fields, it does not matter and generates less overhead, so we just use it.






        share|improve this answer























        • Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
          – Khanna111
          Aug 6 '15 at 18:42






        • 2




          @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Aug 6 '15 at 18:50






        • 4




          This should be the actual answer.
          – Ramazan Polat
          Nov 6 '16 at 5:41






        • 5




          On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
          – PhilipS
          Apr 25 '17 at 2:03








        • 2




          A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
          – Bernard
          Jul 3 '17 at 12:34













        up vote
        332
        down vote










        up vote
        332
        down vote










        when should we use it




        Quentin's answer is right: use multipart/form-data if the form contains a file upload, and application/x-www-form-urlencoded otherwise, which is the default if you omit enctype.



        I'm going to:




        • add some more HTML5 references

        • explain why he is right with a form submit example


        HTML5 references



        There are three possibilities for enctype:




        • x-www-urlencoded


        • multipart/form-data (spec points to RFC7578)


        • text-plain. This is "not reliably interpretable by computer", so it should never be used in production, and we will not look further into it.


        How to generate the examples



        Once you see an example of each method, it becomes obvious how they work, and when you should use each one.



        You can produce examples using:





        • nc -l or an ECHO server: HTTP test server accepting GET/POST requests

        • an user agent like a browser or cURL


        Save the form to a minimal .html file:



        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="utf-8"/>
        <title>upload</title>
        </head>
        <body>
        <form action="http://localhost:8000" method="post" enctype="multipart/form-data">
        <p><input type="text" name="text1" value="text default">
        <p><input type="text" name="text2" value="aωb">
        <p><input type="file" name="file1">
        <p><input type="file" name="file2">
        <p><input type="file" name="file3">
        <p><button type="submit">Submit</button>
        </form>
        </body>
        </html>


        We set the default text value to aωb, which means aωb because ω is U+03C9, which are the bytes 61 CF 89 62 in UTF-8.



        Create files to upload:



        echo 'Content of a.txt.' > a.txt

        echo '<!DOCTYPE html><title>Content of a.html.</title>' > a.html

        # Binary file containing 4 bytes: 'a', 1, 2 and 'b'.
        printf 'axCFx89b' > binary


        Run our little echo server:



        while true; do printf '' | nc -l 8000 localhost; done


        Open the HTML on your browser, select the files and click on submit and check the terminal.



        nc prints the request received.



        Tested on: Ubuntu 14.04.3, nc BSD 1.105, Firefox 40.



        multipart/form-data



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
        Content-Length: 834

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text1"

        text default
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text2"

        aωb
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file1"; filename="a.txt"
        Content-Type: text/plain

        Content of a.txt.

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file2"; filename="a.html"
        Content-Type: text/html

        <!DOCTYPE html><title>Content of a.html.</title>

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file3"; filename="binary"
        Content-Type: application/octet-stream

        aωb
        -----------------------------735323031399963166993862150--


        For the binary file and text field, the bytes 61 CF 89 62 (aωb in UTF-8) are sent literally. You could verify that with nc -l localhost 8000 | hd, which says that the bytes:



        61 CF 89 62


        were sent (61 == 'a' and 62 == 'b').



        Therefore it is clear that:




        • Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 sets the content type to multipart/form-data and says that the fields are separated by the given boundary string.



        • every field gets some sub headers before its data: Content-Disposition: form-data;, the field name, the filename, followed by the data.



          The server reads the data until the next boundary string. The browser must choose a boundary that will not appear in any of the fields, so this is why the boundary may vary between requests.



          Because we have the unique boundary, no encoding of the data is necessary: binary data is sent as is.



          TODO: what is the optimal boundary size (log(N) I bet), and name / running time of the algorithm that finds it? Asked at: https://cs.stackexchange.com/questions/39687/find-the-shortest-sequence-that-is-not-a-sub-sequence-of-a-set-of-sequences




        • Content-Type is automatically determined by the browser.



          How it is determined exactly was asked at: How is mime type of an uploaded file determined by browser?




        application/x-www-form-urlencoded



        Now change the enctype to application/x-www-form-urlencoded, reload the browser, and resubmit.



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: application/x-www-form-urlencoded
        Content-Length: 51

        text1=text+default&text2=a%CF%89b&file1=a.txt&file2=a.html&file3=binary


        Clearly the file data was not sent, only the basenames. So this cannot be used for files.



        As for the text field, we see that usual printable characters like a and b were sent in one byte, while non-printable ones like 0xCF and 0x89 took up 3 bytes each: %CF%89!



        Comparison



        File uploads often contain lots of non-printable characters (e.g. images), while text forms almost never do.



        From the examples we have seen that:




        • multipart/form-data: adds a few bytes of boundary overhead to the message, and must spend some time calculating it, but sends each byte in one byte.


        • application/x-www-form-urlencoded: has a single byte boundary per field (&), but adds a linear overhead factor of 3x for every non-printable character.



        Therefore, even if we could send files with application/x-www-form-urlencoded, we wouldn't want to, because it is so inefficient.



        But for printable characters found in text fields, it does not matter and generates less overhead, so we just use it.






        share|improve this answer















        when should we use it




        Quentin's answer is right: use multipart/form-data if the form contains a file upload, and application/x-www-form-urlencoded otherwise, which is the default if you omit enctype.



        I'm going to:




        • add some more HTML5 references

        • explain why he is right with a form submit example


        HTML5 references



        There are three possibilities for enctype:




        • x-www-urlencoded


        • multipart/form-data (spec points to RFC7578)


        • text-plain. This is "not reliably interpretable by computer", so it should never be used in production, and we will not look further into it.


        How to generate the examples



        Once you see an example of each method, it becomes obvious how they work, and when you should use each one.



        You can produce examples using:





        • nc -l or an ECHO server: HTTP test server accepting GET/POST requests

        • an user agent like a browser or cURL


        Save the form to a minimal .html file:



        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="utf-8"/>
        <title>upload</title>
        </head>
        <body>
        <form action="http://localhost:8000" method="post" enctype="multipart/form-data">
        <p><input type="text" name="text1" value="text default">
        <p><input type="text" name="text2" value="aωb">
        <p><input type="file" name="file1">
        <p><input type="file" name="file2">
        <p><input type="file" name="file3">
        <p><button type="submit">Submit</button>
        </form>
        </body>
        </html>


        We set the default text value to aωb, which means aωb because ω is U+03C9, which are the bytes 61 CF 89 62 in UTF-8.



        Create files to upload:



        echo 'Content of a.txt.' > a.txt

        echo '<!DOCTYPE html><title>Content of a.html.</title>' > a.html

        # Binary file containing 4 bytes: 'a', 1, 2 and 'b'.
        printf 'axCFx89b' > binary


        Run our little echo server:



        while true; do printf '' | nc -l 8000 localhost; done


        Open the HTML on your browser, select the files and click on submit and check the terminal.



        nc prints the request received.



        Tested on: Ubuntu 14.04.3, nc BSD 1.105, Firefox 40.



        multipart/form-data



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
        Content-Length: 834

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text1"

        text default
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="text2"

        aωb
        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file1"; filename="a.txt"
        Content-Type: text/plain

        Content of a.txt.

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file2"; filename="a.html"
        Content-Type: text/html

        <!DOCTYPE html><title>Content of a.html.</title>

        -----------------------------735323031399963166993862150
        Content-Disposition: form-data; name="file3"; filename="binary"
        Content-Type: application/octet-stream

        aωb
        -----------------------------735323031399963166993862150--


        For the binary file and text field, the bytes 61 CF 89 62 (aωb in UTF-8) are sent literally. You could verify that with nc -l localhost 8000 | hd, which says that the bytes:



        61 CF 89 62


        were sent (61 == 'a' and 62 == 'b').



        Therefore it is clear that:




        • Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 sets the content type to multipart/form-data and says that the fields are separated by the given boundary string.



        • every field gets some sub headers before its data: Content-Disposition: form-data;, the field name, the filename, followed by the data.



          The server reads the data until the next boundary string. The browser must choose a boundary that will not appear in any of the fields, so this is why the boundary may vary between requests.



          Because we have the unique boundary, no encoding of the data is necessary: binary data is sent as is.



          TODO: what is the optimal boundary size (log(N) I bet), and name / running time of the algorithm that finds it? Asked at: https://cs.stackexchange.com/questions/39687/find-the-shortest-sequence-that-is-not-a-sub-sequence-of-a-set-of-sequences




        • Content-Type is automatically determined by the browser.



          How it is determined exactly was asked at: How is mime type of an uploaded file determined by browser?




        application/x-www-form-urlencoded



        Now change the enctype to application/x-www-form-urlencoded, reload the browser, and resubmit.



        Firefox sent:



        POST / HTTP/1.1
        [[ Less interesting headers ... ]]
        Content-Type: application/x-www-form-urlencoded
        Content-Length: 51

        text1=text+default&text2=a%CF%89b&file1=a.txt&file2=a.html&file3=binary


        Clearly the file data was not sent, only the basenames. So this cannot be used for files.



        As for the text field, we see that usual printable characters like a and b were sent in one byte, while non-printable ones like 0xCF and 0x89 took up 3 bytes each: %CF%89!



        Comparison



        File uploads often contain lots of non-printable characters (e.g. images), while text forms almost never do.



        From the examples we have seen that:




        • multipart/form-data: adds a few bytes of boundary overhead to the message, and must spend some time calculating it, but sends each byte in one byte.


        • application/x-www-form-urlencoded: has a single byte boundary per field (&), but adds a linear overhead factor of 3x for every non-printable character.



        Therefore, even if we could send files with application/x-www-form-urlencoded, we wouldn't want to, because it is so inefficient.



        But for printable characters found in text fields, it does not matter and generates less overhead, so we just use it.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 21 at 15:49

























        answered Feb 7 '15 at 9:52









        Ciro Santilli 新疆改造中心 六四事件 法轮功

        134k30524451




        134k30524451












        • Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
          – Khanna111
          Aug 6 '15 at 18:42






        • 2




          @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Aug 6 '15 at 18:50






        • 4




          This should be the actual answer.
          – Ramazan Polat
          Nov 6 '16 at 5:41






        • 5




          On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
          – PhilipS
          Apr 25 '17 at 2:03








        • 2




          A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
          – Bernard
          Jul 3 '17 at 12:34


















        • Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
          – Khanna111
          Aug 6 '15 at 18:42






        • 2




          @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Aug 6 '15 at 18:50






        • 4




          This should be the actual answer.
          – Ramazan Polat
          Nov 6 '16 at 5:41






        • 5




          On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
          – PhilipS
          Apr 25 '17 at 2:03








        • 2




          A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
          – Bernard
          Jul 3 '17 at 12:34
















        Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
        – Khanna111
        Aug 6 '15 at 18:42




        Great post. Question: Why do we have 3 bytes for each non printable character? For eg: for unicode U+03C9, we have %CF%89: this is 2 extra bytes for the two "%". Is my understanding correct?
        – Khanna111
        Aug 6 '15 at 18:42




        2




        2




        @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
        – Ciro Santilli 新疆改造中心 六四事件 法轮功
        Aug 6 '15 at 18:50




        @Khanna111%CF is 3 bytes long: %, C and F :-) Story of making it human readable.
        – Ciro Santilli 新疆改造中心 六四事件 法轮功
        Aug 6 '15 at 18:50




        4




        4




        This should be the actual answer.
        – Ramazan Polat
        Nov 6 '16 at 5:41




        This should be the actual answer.
        – Ramazan Polat
        Nov 6 '16 at 5:41




        5




        5




        On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
        – PhilipS
        Apr 25 '17 at 2:03






        On OS X, nc won't accept both the -l and the -p arguments simultaneously. But this works for me: while true; do printf '' | nc -l 8000; done.
        – PhilipS
        Apr 25 '17 at 2:03






        2




        2




        A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
        – Bernard
        Jul 3 '17 at 12:34




        A small but important point that isn't mentioned is that the boundary specified in the Content-Type has two hyphens (--) less, i.e. when actually using the boundary in the message body, you must prefix it with --. Also, the last boundary must be suffixed with --, but that is easy enough to notice. See stackoverflow.com/questions/3508252/…
        – Bernard
        Jul 3 '17 at 12:34










        up vote
        76
        down vote













        enctype='multipart/form-data is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.



        If you want to allow a user to upload a file via a form, you must use this enctype.






        share|improve this answer























        • So.. if the file is not a binary file then can we work without this ?
          – Yugal Jindle
          Aug 27 '13 at 0:01










        • From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
          – Matt Asbury
          Aug 27 '13 at 9:36








        • 8




          The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
          – Daniel Luna
          Sep 19 '13 at 17:34






        • 5




          Its worth pointing out you can base64 encode your image and send it as plain string data .
          – Prospero
          Jul 14 '14 at 22:46















        up vote
        76
        down vote













        enctype='multipart/form-data is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.



        If you want to allow a user to upload a file via a form, you must use this enctype.






        share|improve this answer























        • So.. if the file is not a binary file then can we work without this ?
          – Yugal Jindle
          Aug 27 '13 at 0:01










        • From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
          – Matt Asbury
          Aug 27 '13 at 9:36








        • 8




          The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
          – Daniel Luna
          Sep 19 '13 at 17:34






        • 5




          Its worth pointing out you can base64 encode your image and send it as plain string data .
          – Prospero
          Jul 14 '14 at 22:46













        up vote
        76
        down vote










        up vote
        76
        down vote









        enctype='multipart/form-data is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.



        If you want to allow a user to upload a file via a form, you must use this enctype.






        share|improve this answer














        enctype='multipart/form-data is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.



        If you want to allow a user to upload a file via a form, you must use this enctype.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 12 '12 at 11:30









        Habeeb Perwad

        3,3711163108




        3,3711163108










        answered Dec 24 '10 at 12:49









        Matt Asbury

        4,8231628




        4,8231628












        • So.. if the file is not a binary file then can we work without this ?
          – Yugal Jindle
          Aug 27 '13 at 0:01










        • From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
          – Matt Asbury
          Aug 27 '13 at 9:36








        • 8




          The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
          – Daniel Luna
          Sep 19 '13 at 17:34






        • 5




          Its worth pointing out you can base64 encode your image and send it as plain string data .
          – Prospero
          Jul 14 '14 at 22:46


















        • So.. if the file is not a binary file then can we work without this ?
          – Yugal Jindle
          Aug 27 '13 at 0:01










        • From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
          – Matt Asbury
          Aug 27 '13 at 9:36








        • 8




          The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
          – Daniel Luna
          Sep 19 '13 at 17:34






        • 5




          Its worth pointing out you can base64 encode your image and send it as plain string data .
          – Prospero
          Jul 14 '14 at 22:46
















        So.. if the file is not a binary file then can we work without this ?
        – Yugal Jindle
        Aug 27 '13 at 0:01




        So.. if the file is not a binary file then can we work without this ?
        – Yugal Jindle
        Aug 27 '13 at 0:01












        From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
        – Matt Asbury
        Aug 27 '13 at 9:36






        From what I understand, you can use multipart/form-data for sending non-binary files but it is inefficient. I believe using application/x-www-form-urlencoded is the correct way to send non-binary data but someone with more experience with non-binary files may need to correct me.
        – Matt Asbury
        Aug 27 '13 at 9:36






        8




        8




        The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
        – Daniel Luna
        Sep 19 '13 at 17:34




        The main advantage to using multipart/form-data for sending a file is that it will work automatically in both frontend and backend. You don't have to do any special handling. All files are binary even if they should only contain text. application/x-www-form-urlencoded is the standard way to POST a form without attached files. multipart/form-data is the standard way to POST a form with attached file(s). (There are also numerous other encodings, such as application/json and application/json-patch+json, which are common for communication between server and client.)
        – Daniel Luna
        Sep 19 '13 at 17:34




        5




        5




        Its worth pointing out you can base64 encode your image and send it as plain string data .
        – Prospero
        Jul 14 '14 at 22:46




        Its worth pointing out you can base64 encode your image and send it as plain string data .
        – Prospero
        Jul 14 '14 at 22:46










        up vote
        69
        down vote













        When submitting a form, you're trying to say your browser to send via the HTTP protocol a message on the network properly enveloped in a TCP/IP protocol message structure. When sending data, you can use POST or GET methods to send data using HTTP protocol. POST tells your browser to build an HTTP message and put all content in the body of the message (a very useful way of doing things, more safe and also flexible). GET has some constraints about data representation and length.



        Stating what you send



        When sending a file, it is necessary to tell the HTTP protocol that you are sending a file having several characteristics and information inside it. In this way it is possible to consistently send data to receiver and let it open the file with the current format and so on...
        This is a requirement from the HTTP protocol as shown here



        You cannot send files using default enctype parameters because your receiver might encounter problems reading it (consider that a file is a descriptor for some data for a specific operating system, if you see things this way, maybe you'll understand why it is so important to specify a different enctype for files).



        Do not forget security



        This way of doing things also ensures that some security algorithms work on your messages. This information is also used by application-level routers in order to act as good firewalls for external data.



        Well, as you can see, it is not a stupid thing using a specific enctype for files.






        share|improve this answer



















        • 5




          header of the message or body of the message?
          – manikanta
          Apr 4 '13 at 12:52






        • 1




          The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
          – Andry
          Apr 4 '13 at 21:13










        • I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
          – Jondlm
          Nov 8 '13 at 6:13










        • Hi All! yes you are all right, I fixed the answer already some time ago...
          – Andry
          Sep 17 '17 at 18:50















        up vote
        69
        down vote













        When submitting a form, you're trying to say your browser to send via the HTTP protocol a message on the network properly enveloped in a TCP/IP protocol message structure. When sending data, you can use POST or GET methods to send data using HTTP protocol. POST tells your browser to build an HTTP message and put all content in the body of the message (a very useful way of doing things, more safe and also flexible). GET has some constraints about data representation and length.



        Stating what you send



        When sending a file, it is necessary to tell the HTTP protocol that you are sending a file having several characteristics and information inside it. In this way it is possible to consistently send data to receiver and let it open the file with the current format and so on...
        This is a requirement from the HTTP protocol as shown here



        You cannot send files using default enctype parameters because your receiver might encounter problems reading it (consider that a file is a descriptor for some data for a specific operating system, if you see things this way, maybe you'll understand why it is so important to specify a different enctype for files).



        Do not forget security



        This way of doing things also ensures that some security algorithms work on your messages. This information is also used by application-level routers in order to act as good firewalls for external data.



        Well, as you can see, it is not a stupid thing using a specific enctype for files.






        share|improve this answer



















        • 5




          header of the message or body of the message?
          – manikanta
          Apr 4 '13 at 12:52






        • 1




          The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
          – Andry
          Apr 4 '13 at 21:13










        • I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
          – Jondlm
          Nov 8 '13 at 6:13










        • Hi All! yes you are all right, I fixed the answer already some time ago...
          – Andry
          Sep 17 '17 at 18:50













        up vote
        69
        down vote










        up vote
        69
        down vote









        When submitting a form, you're trying to say your browser to send via the HTTP protocol a message on the network properly enveloped in a TCP/IP protocol message structure. When sending data, you can use POST or GET methods to send data using HTTP protocol. POST tells your browser to build an HTTP message and put all content in the body of the message (a very useful way of doing things, more safe and also flexible). GET has some constraints about data representation and length.



        Stating what you send



        When sending a file, it is necessary to tell the HTTP protocol that you are sending a file having several characteristics and information inside it. In this way it is possible to consistently send data to receiver and let it open the file with the current format and so on...
        This is a requirement from the HTTP protocol as shown here



        You cannot send files using default enctype parameters because your receiver might encounter problems reading it (consider that a file is a descriptor for some data for a specific operating system, if you see things this way, maybe you'll understand why it is so important to specify a different enctype for files).



        Do not forget security



        This way of doing things also ensures that some security algorithms work on your messages. This information is also used by application-level routers in order to act as good firewalls for external data.



        Well, as you can see, it is not a stupid thing using a specific enctype for files.






        share|improve this answer














        When submitting a form, you're trying to say your browser to send via the HTTP protocol a message on the network properly enveloped in a TCP/IP protocol message structure. When sending data, you can use POST or GET methods to send data using HTTP protocol. POST tells your browser to build an HTTP message and put all content in the body of the message (a very useful way of doing things, more safe and also flexible). GET has some constraints about data representation and length.



        Stating what you send



        When sending a file, it is necessary to tell the HTTP protocol that you are sending a file having several characteristics and information inside it. In this way it is possible to consistently send data to receiver and let it open the file with the current format and so on...
        This is a requirement from the HTTP protocol as shown here



        You cannot send files using default enctype parameters because your receiver might encounter problems reading it (consider that a file is a descriptor for some data for a specific operating system, if you see things this way, maybe you'll understand why it is so important to specify a different enctype for files).



        Do not forget security



        This way of doing things also ensures that some security algorithms work on your messages. This information is also used by application-level routers in order to act as good firewalls for external data.



        Well, as you can see, it is not a stupid thing using a specific enctype for files.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 2 '17 at 6:42

























        answered Dec 24 '10 at 17:50









        Andry

        6,5492089177




        6,5492089177








        • 5




          header of the message or body of the message?
          – manikanta
          Apr 4 '13 at 12:52






        • 1




          The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
          – Andry
          Apr 4 '13 at 21:13










        • I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
          – Jondlm
          Nov 8 '13 at 6:13










        • Hi All! yes you are all right, I fixed the answer already some time ago...
          – Andry
          Sep 17 '17 at 18:50














        • 5




          header of the message or body of the message?
          – manikanta
          Apr 4 '13 at 12:52






        • 1




          The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
          – Andry
          Apr 4 '13 at 21:13










        • I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
          – Jondlm
          Nov 8 '13 at 6:13










        • Hi All! yes you are all right, I fixed the answer already some time ago...
          – Andry
          Sep 17 '17 at 18:50








        5




        5




        header of the message or body of the message?
        – manikanta
        Apr 4 '13 at 12:52




        header of the message or body of the message?
        – manikanta
        Apr 4 '13 at 12:52




        1




        1




        The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
        – Andry
        Apr 4 '13 at 21:13




        The information about the enctype is part of the header. If you send a file, the body of the http message is the bytestream of the file.
        – Andry
        Apr 4 '13 at 21:13












        I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
        – Jondlm
        Nov 8 '13 at 6:13




        I agree with @manikanta, I'm pretty sure a POST sends the data in the body of the request
        – Jondlm
        Nov 8 '13 at 6:13












        Hi All! yes you are all right, I fixed the answer already some time ago...
        – Andry
        Sep 17 '17 at 18:50




        Hi All! yes you are all right, I fixed the answer already some time ago...
        – Andry
        Sep 17 '17 at 18:50










        up vote
        29
        down vote













        enctype='multipart/form-data' means that no characters will be encoded. that is why this type is used while uploading files to server.

        So multipart/form-data is used when a form requires binary data, like the contents of a file, to be uploaded






        share|improve this answer



























          up vote
          29
          down vote













          enctype='multipart/form-data' means that no characters will be encoded. that is why this type is used while uploading files to server.

          So multipart/form-data is used when a form requires binary data, like the contents of a file, to be uploaded






          share|improve this answer

























            up vote
            29
            down vote










            up vote
            29
            down vote









            enctype='multipart/form-data' means that no characters will be encoded. that is why this type is used while uploading files to server.

            So multipart/form-data is used when a form requires binary data, like the contents of a file, to be uploaded






            share|improve this answer














            enctype='multipart/form-data' means that no characters will be encoded. that is why this type is used while uploading files to server.

            So multipart/form-data is used when a form requires binary data, like the contents of a file, to be uploaded







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 13 '14 at 21:09









            Volker E.

            4,235103862




            4,235103862










            answered Jul 4 '13 at 9:13









            GP Singh

            443411




            443411






















                up vote
                9
                down vote













                Set the method attribute to POST because file content can't be put inside a URL parameter using a form.



                Set the value of enctype to multipart/form-data because the data will be split into multiple parts, one for each file plus one for the text of the form body that may be sent with them.






                share|improve this answer





















                • This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                  – underscore_d
                  Jun 11 '17 at 12:33















                up vote
                9
                down vote













                Set the method attribute to POST because file content can't be put inside a URL parameter using a form.



                Set the value of enctype to multipart/form-data because the data will be split into multiple parts, one for each file plus one for the text of the form body that may be sent with them.






                share|improve this answer





















                • This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                  – underscore_d
                  Jun 11 '17 at 12:33













                up vote
                9
                down vote










                up vote
                9
                down vote









                Set the method attribute to POST because file content can't be put inside a URL parameter using a form.



                Set the value of enctype to multipart/form-data because the data will be split into multiple parts, one for each file plus one for the text of the form body that may be sent with them.






                share|improve this answer












                Set the method attribute to POST because file content can't be put inside a URL parameter using a form.



                Set the value of enctype to multipart/form-data because the data will be split into multiple parts, one for each file plus one for the text of the form body that may be sent with them.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 25 '13 at 11:53









                sandy

                36039




                36039












                • This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                  – underscore_d
                  Jun 11 '17 at 12:33


















                • This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                  – underscore_d
                  Jun 11 '17 at 12:33
















                This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                – underscore_d
                Jun 11 '17 at 12:33




                This implies that POST is likely to be sufficient for submitting a file via a form and that adding multipart/form-data is just a bonus in some vague way. That's not the case. Most files will absolutely require using multipart/form-data.
                – underscore_d
                Jun 11 '17 at 12:33










                up vote
                1
                down vote













                Usually this is when you have a POST form which needs to take a file upload as data... this will tell the server how it will encode the data transferred, in such case it won't get encoded because it will just transfer and upload the files to the server, Like for example when uploading an image or a pdf






                share|improve this answer

























                  up vote
                  1
                  down vote













                  Usually this is when you have a POST form which needs to take a file upload as data... this will tell the server how it will encode the data transferred, in such case it won't get encoded because it will just transfer and upload the files to the server, Like for example when uploading an image or a pdf






                  share|improve this answer























                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    Usually this is when you have a POST form which needs to take a file upload as data... this will tell the server how it will encode the data transferred, in such case it won't get encoded because it will just transfer and upload the files to the server, Like for example when uploading an image or a pdf






                    share|improve this answer












                    Usually this is when you have a POST form which needs to take a file upload as data... this will tell the server how it will encode the data transferred, in such case it won't get encoded because it will just transfer and upload the files to the server, Like for example when uploading an image or a pdf







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 10 '16 at 9:29









                    Eric

                    123112




                    123112






















                        up vote
                        1
                        down vote














                        • enctype(ENCode TYPE) attribute specifies how the form-data should be encoded when submitting it to the server.


                        • multipart/form-data is one of the value of enctype attribute, which is used in form element that have a file upload. multi-part means form data divides into multiple parts and send to server.


                          • metaphor part : an HTML document has two parts: a head and a body.








                        share|improve this answer



















                        • 4




                          I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                          – Yeo
                          Mar 3 '16 at 11:00

















                        up vote
                        1
                        down vote














                        • enctype(ENCode TYPE) attribute specifies how the form-data should be encoded when submitting it to the server.


                        • multipart/form-data is one of the value of enctype attribute, which is used in form element that have a file upload. multi-part means form data divides into multiple parts and send to server.


                          • metaphor part : an HTML document has two parts: a head and a body.








                        share|improve this answer



















                        • 4




                          I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                          – Yeo
                          Mar 3 '16 at 11:00















                        up vote
                        1
                        down vote










                        up vote
                        1
                        down vote










                        • enctype(ENCode TYPE) attribute specifies how the form-data should be encoded when submitting it to the server.


                        • multipart/form-data is one of the value of enctype attribute, which is used in form element that have a file upload. multi-part means form data divides into multiple parts and send to server.


                          • metaphor part : an HTML document has two parts: a head and a body.








                        share|improve this answer















                        • enctype(ENCode TYPE) attribute specifies how the form-data should be encoded when submitting it to the server.


                        • multipart/form-data is one of the value of enctype attribute, which is used in form element that have a file upload. multi-part means form data divides into multiple parts and send to server.


                          • metaphor part : an HTML document has two parts: a head and a body.









                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 8 '17 at 0:12

























                        answered Dec 27 '15 at 1:29









                        Premraj

                        28.6k10150116




                        28.6k10150116








                        • 4




                          I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                          – Yeo
                          Mar 3 '16 at 11:00
















                        • 4




                          I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                          – Yeo
                          Mar 3 '16 at 11:00










                        4




                        4




                        I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                        – Yeo
                        Mar 3 '16 at 11:00






                        I believe enctype does not stand for encryption type. There is no encryption involved at this level. My guess is either encoding type or enclosed type. But surely it is not encryption type.
                        – Yeo
                        Mar 3 '16 at 11:00












                        up vote
                        1
                        down vote














                        The enctype attribute specifies how the form-data should be encoded when submitting it to the server.



                        The enctype attribute can be used only if method="post".



                        No characters are encoded. This value is required when you are using forms that have a file upload control




                        From W3Schools






                        share|improve this answer



























                          up vote
                          1
                          down vote














                          The enctype attribute specifies how the form-data should be encoded when submitting it to the server.



                          The enctype attribute can be used only if method="post".



                          No characters are encoded. This value is required when you are using forms that have a file upload control




                          From W3Schools






                          share|improve this answer

























                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote










                            The enctype attribute specifies how the form-data should be encoded when submitting it to the server.



                            The enctype attribute can be used only if method="post".



                            No characters are encoded. This value is required when you are using forms that have a file upload control




                            From W3Schools






                            share|improve this answer















                            The enctype attribute specifies how the form-data should be encoded when submitting it to the server.



                            The enctype attribute can be used only if method="post".



                            No characters are encoded. This value is required when you are using forms that have a file upload control




                            From W3Schools







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 14 at 2:25









                            Pang

                            6,8501563101




                            6,8501563101










                            answered Nov 11 at 22:52









                            Rishad

                            179110




                            179110

















                                protected by NINCOMPOOP Nov 4 '13 at 7:17



                                Thank you for your interest in this question.
                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                Would you like to answer one of these unanswered questions instead?



                                Popular posts from this blog

                                Florida Star v. B. J. F.

                                Error while running script in elastic search , gateway timeout

                                Adding quotations to stringified JSON object values