curl-library
uploading / renaming - using anonymous / non anonymous account
Date: Wed, 13 Mar 2002 12:10:19 -0000
Hi all,
I have this piece of code doing fine when using relative path when using an
anonymous account.
example : delivery_dir_path="pub/upload"
When I use an non anonymous account, I need to define the path as an
absolute path.
example : delivery_dir_path="/home/theaccount/upload"
Does anyone have suggestion to transform this code in order to manage with
relative path
either using anonymous or non anonymous accounts ?
Many thanks
erick nuwendam
char rnfr_cmd [255] ;
char rnto_cmd [255] ;
struct curl_slist *headerlist=NULL;
// CURL init
curl = NULL ;
headerlist = NULL ;
curl = curl_easy_init();
if (curl==NULL) {
exit(0) ;
}
sprintf(rnfr_cmd,"RNFR /%s/%s", delivery_dir_path,"tmp_file") ;
sprintf(rnto_cmd,"RNTO /%s/%s", delivery_dir_path,"final_file") ;
headerlist = curl_slist_append(headerlist, rnfr_cmd);
headerlist = curl_slist_append(headerlist, rnto_cmd);
// open the local file
hd_src = fopen("file_to_send", "rb");
curl_easy_setopt(curl, CURLOPT_UPLOAD,true) ;
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, 455);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_msg_buffer);
sprintf(URL,"ftp://%s:%s@%s/%s/%s",
"mylogin",
"mypassword",
"thehost",
delivery_dir_path,
"tmp_file") ;
curl_easy_setopt(curl, CURLOPT_URL, URL); // read '@'
res = curl_easy_perform(curl);
// close the local file
fclose (hd_src) ;
Received on 2002-03-13