As docs/examples/postit2.c sample code, as document [1] indicated, all you need to do is call curl_formadd for each file you want to upload:
curl_formadd(&post, &last, CURLFORM_COPYNAME, "Foo", CURLFORM_FILE, "foo.txt", CURLFORM_END); curl_formadd(&post, &last, CURLFORM_COPYNAME, "Bar", CURLFORM_FILE, "bar.txt", CURLFORM_END); /* ... */
Note that I used the CURLFORM_FILE parameter instead of CURLFORM_FILECONTENT , which forces this file to be read, and its contents are used as data in this part. Be sure to use the appropriate option by checking the document [1].
Pro-tip: you can easily test your code with a debugging service like httpbin or echohttp .
[1]
For CURLFORM_FILE, the user can send one or more files in one piece by supplying several CURLFORM_FILE arguments followed by the file name.
source share