c++ - curl_easy_perform() failed: failed FTP upload (the STOR command) error -


i have been unsuccessful in uploading file onto ftp server "curl_easy_perform() failed: failed ftp upload (the stor command) " error.i googled lot can't find solution or suggestion. here tiny code

#define local_file      "d:/er.txt"       #define remote_url      "ftp://ftp.nso.edu/incoming/"   using namespace std;   static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) {   curl_off_t nread;    size_t retcode = fread(ptr, size, nmemb, (file*)stream);    nread = (curl_off_t)retcode;    fprintf(stderr, "*** read %" curl_format_curl_off_t           " bytes file\n", nread);   return retcode; }   int main() {     curl *curl;   curlcode res;   file *hd_src;   struct stat file_info;   curl_off_t fsize;    struct curl_slist *headerlist=null;     /* file size of local file */    if(stat(local_file, &file_info)) {     printf("couldnt open '%s': %s\n", local_file, strerror(errno));     return 1;   }   fsize = (curl_off_t)file_info.st_size;    printf("local file size: %" curl_format_curl_off_t " bytes.\n", fsize);    /* file * of same file */    hd_src = fopen(local_file, "rb");    /* in windows, init winsock stuff */    curl_global_init(curl_global_all);    /* curl handle */    curl = curl_easy_init();   if(curl) {       /* want use our own read function */      curl_easy_setopt(curl, curlopt_readfunction, read_callback);      /* enable uploading */      curl_easy_setopt(curl, curlopt_upload, 1l);      /* specify target */      curl_easy_setopt(curl,curlopt_url, remote_url);      /* pass in last of ftp commands run after transfer */      curl_easy_setopt(curl, curlopt_postquote, headerlist);      /* specify file upload */      curl_easy_setopt(curl, curlopt_readdata, hd_src);      /* set size of file upload (optional).  if give *_large        option must make sure type of passed-in argument        curl_off_t. if use curlopt_infilesize (without _large) must        make sure pass in type 'long' argument. */      curl_easy_setopt(curl, curlopt_infilesize_large,                      (curl_off_t)fsize);      /* run off , you've been told! */      res = curl_easy_perform(curl);     /* check errors */      if(res != curle_ok)       fprintf(stderr, "curl_easy_perform() failed: %s\n",               curl_easy_strerror(res));      /* clean ftp commands list */      curl_slist_free_all (headerlist);      /* cleanup */      curl_easy_cleanup(curl);   }   fclose(hd_src); /* close local file */     curl_global_cleanup();                // wait keystroke    getch();   return 0; } 

set

curl_easy_setopt(curl, curlopt_errorbuffer, char* allocatedmemoryforerrorbuffer); 

the character pointer have bit more detail error occurring. typically, works http requests understanding should work ftp well.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -