curl-users
RE: Help required...
Date: Wed, 4 Jul 2001 13:05:46 +0200
> Hey Nielsen,
Psst! It's "Linus". :-)
> TQ 4 yr speedy reply,
Always on my toes... :-)
> I shall look into the MSDN pages for Dll creation..
> And I think I have understood what the
> curl_easy_setopt() function does...I shall try it
> out..
> :)
Great!
> Nielsen, what changes do we have to make to ftpget.c to
> make it upload a file into an FTPServer. I tried using
> the following Statements...It did not work :(
>
> curl_easy_setopt(curl, CURLOPT_URL, "ftp://ip/dir");
> curl_easy_setopt(curl, CURLOPT_UPLOAD, 3);
> curl_easy_setopt(curl, CURLOPT_FILE, ftpfile);
> curl_easy_perform(curl);
>
> Please help me out,
You are close. First, you have to open the file for reading
instad of writing:
ftpfile = fopen("myfile", "rb"); /* b is binary for win */
Then you have to include the file name in the URL:
curl_easy_setopt(curl, CURLOPT_URL, "ftp://[host]/[dir]/[filename]");
Unless you are uploading anonymously, you have to set the
user/password:
curl_easy_setopt(curl, CURLOPT_USERPWD, "[username]:[password]");
Then the rest of the stuff:
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
Shazam!
One caveat, though. If you have built libcurl as a DLL, you have to
do it in a slightly different way, but since I know you built a static
library, this will work for you.
/Linus
Received on 2001-07-04