curl-users
Upload and rename
Date: Tue, 28 Aug 2001 13:26:58 -0000
Hello,
No problem to submit this as an example but the only thing that
remains is that the rename does not work.
Have you an idea ?
Am I wrong with CURL calls?
Thanks.
#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 [] = "RENAME FROM toto.txt";
char buf_2 [] = "RENAME TO 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) ;
curl_easy_setopt(curl,
CURLOPT_URL,
"ftp://root:passwd@192.168.200.211/toto.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