How to use Chrome's "Copy as cURL" for multipart/form-data post requests on Windows? How to use Chrome's "Copy as cURL" for multipart/form-data post requests on Windows? windows windows

How to use Chrome's "Copy as cURL" for multipart/form-data post requests on Windows?


Chrome, as well as the other browsers actually, do a rather poor job of translating multi-part formposts into curl command lines.

A much more convenient curl command line would not use --data-binary for that, it would use --form. And then you want one --form per input field.

In your case, it probably would look something like (backslashes inserted herefor visibility):

curl "http://myserver.local" \ --compressed \ -H "Origin: http://wiki.selfhtml.org" \ -A "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36" \ -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \ -H "Cache-Control: max-age=0" \ -e "http://wiki.selfhtml.org/extensions/Selfhtml/frickl.php/Beispiel:HTML_form-Element1.html" \ -F area=[contents]

I left the [contents] in there, but it should be replaced with what you actually want in the area field. You could also pass it from a file if you prefer to.

I removed two unnecessary -H uses, and I replaced two to use the direct curl options.

h2c - headers to curl

Advice for the future: figure out the exact HTTP header trace you want to reproduce with a curl command line and paste it over at https://curl.se/h2c/ .