curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How to send form data?

From: Nicolas Sterchele via curl-users <curl-users_at_cool.haxx.se>
Date: Tue, 7 Jul 2020 08:52:56 +0200

On 2020-07-06 18:30, Peng Yu via curl-users wrote:
>I see the following form data in chrome browser devtools for a POST
>request. But the file content is not included due to a limitation in
>devtools. Could anybody let me know how to call curl to send this form
>data with the proper file content loaded? (I know the option of ` -F
>file="@27098227.pdf"`, I am not sure how to combine it with the other
>form data in this request.) Thanks.
>
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="name"
>
>27098227.pdf
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="chunk"
>
>0
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="chunks"
>
>1
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="task"
>
>t50Ap8gfmsfzmd1f9pktlAzcmbv9s3kpxxvjA4mqsycbmx66nl1bm7jc7h4j465zdm5hz2hvccqmlhy9hA6yn3tn590w3ld9yA7smb7dqj7kczdr9AjA3m7hAb1xpr4ys6zr4s0ryzpkl85b24vtp3hAz2w6bj6l6xc16dg384w7qmlt7hxq
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="preview"
>
>1
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="pdfinfo"
>
>0
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="v"
>
>web.0
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe
>Content-Disposition: form-data; name="file"; filename="27098227.pdf"
>Content-Type: application/pdf
>
>
>------WebKitFormBoundaryBUU5EAq8M5IgOHNe--
>
>--
>Regards,
>Peng

You can also use the -F option to send out your form data in addition to
the file:
curl -F name=27098227.pdf -F preview=0 -F v=web.0 --trace-ascii /dev/stdout http://your-url.com

I've added the --trace-ascii option to output the form params on stdout.

Nicolas.
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-07-07