curl-users
Upload and rename : thank you
Date: Tue, 28 Aug 2001 13:56:31 -0000
Hello,
Thanks for your advices.
Now upload and rename are OK with the code below.
Thanks.
PS : I did not read RFC
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
int main(int argc, char **argv)
{
CURL *curl;
CURLcode res;
FILE *ftpfile;
FILE * hd_src ;
int hd ;
struct stat file_info;
struct curl_slist *headerlist=NULL;
char buf_1 [] = "RNFR toto.txt";
char buf_2 [] = "RNTO erick.txt";
hd = open("/tmp/rocket",O_RDONLY) ;
fstat(hd, &file_info);
close(hd) ;
/* local file name to store the file as */
hd_src = fopen("/tmp/rocket", "rb");
curl = curl_easy_init();
if(curl) {
headerlist = curl_slist_append(headerlist, buf_1);
headerlist = curl_slist_append(headerlist, buf_2);
curl_easy_setopt(curl, CURLOPT_UPLOAD,true) ;
curl_easy_setopt(curl,CURLOPT_URL,"ftp://root:rootpasswd@192.168.200.211/tot
o.txt"); // read '@'
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size);
res = curl_easy_perform(curl);
curl_slist_free_all (headerlist);
/* always cleanup */
curl_easy_cleanup(curl);
}
fclose(hd_src); /* close the local file */
return 0;
}
Received on 2001-08-28