cUrl command line to libcurl source code...

Hello !

I have a simple (working) cUrl command line:

curl -u user:pass -F "filename=test.txt" -F "fname=@foo.txt" http://www.myserver.com/fileupload.htm

Do you have any idea how i could execute this in a c++ app using the libcurl library ?

Thank you for any hint/help !

Greetings,

Nils
Like this:
http://curl.haxx.se/libcurl/c/postit2.html

As for the username and password, you either specify them in the URL itself, or you use CURLOPT_USERPWD option.
Hi !
Thank you for the quick info i took a quick look.
It seems that this:

curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "fname",
CURLFORM_FILE, "foo.txt",
CURLFORM_END);

Is the equivalent of the -F"fname=@foo.txt", right ?


And this is the equivalent of -F "filename=test.txt" :

curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filename",
CURLFORM_COPYCONTENTS, "test.txt",
CURLFORM_END);


Am i correct, that would be GREAT.

If not, please point out my mistake :-)

THANK YOU,
Nils
Last edited on
Topic archived. No new replies allowed.