3

I have read some stuff about form data encoding, but one thing remains unclear. In case of enctype="application/x-www-form-urlencoded" we need to urlencode data by hand, don't we?

... Forms submitted with this content type must be encoded as follows

Must be encoded by whom? By browsers? Or by application developers?

The other thing is -- what encoding (if any) is used, or should be used, in case of multipart/form-data?

I'm kindda mislead so big thx in advance.

Community
  • 1
  • 1
Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68
  • That depends on how the POST is being generated. – SLaks Dec 17 '12 at 18:46
  • 1
    Great answer, it all suddenly became so clear, thanks a lot! – Vadim Samokhin Dec 17 '12 at 18:48
  • 1
    If you set the `enctype` attribute of your form to `application/x-www-form-urlencoded`, the browser will automatically encode the form data. Are you having problems with a browser that doesn't encode the values? – Frank van Puffelen Dec 17 '12 at 18:51
  • No, that's the thing - I did not understand who should encode data according to specification. By experimenting I found out that browser makes it, but I still had doubts. But what about multipart/form-data? – Vadim Samokhin Dec 17 '12 at 18:56

1 Answers1

4

Actually, browsers url-encode data automatically. And this w3 docs is first of all for those who make browsers. So that phrase, Forms submitted with this content type must be encoded as follows means that data should be encoded by browsers. Anyway, one can check it by viewing raw post in the form data handling script (in case of php in looks like file_get_contents("php://input");)

Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68