cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Reg:FTP upload in libcurl

From: <nagarajan.sreenivasan_at_wipro.com>
Date: Fri, 20 Jun 2008 09:12:56 +0530

Hi all

>>>>Using what libcurl version on what platform?

Using libcurl version on 17.8.1 and linux .

I am coding in C++.

The below are member fucntions are of class FTP_TEST

This the code for Connect() funciton

Connect()
{
   char * REMOTE_URL=new char[100];
      strcpy(REMOTE_URL,"ftp:// <ftp://> ");

      strncat(REMOTE_URL,userName,strlen(userName));
      strcat(REMOTE_URL,":");
      strncat(REMOTE_URL,passWord,strlen(passWord));
      strcat(REMOTE_URL,"@");
      strncat(REMOTE_URL,hostName,strlen(hostName));

     CurlInternalSettings();
     curl_easy_setopt(curl,CURLOPT_URL,REMOTE_URL);
     res = curl_easy_perform(curl);
}

void CurlInternalSettings()
{
   curl_global_init(CURL_GLOBAL_ALL);

   curl = curl_easy_init();
   if(curl) {
    curl_easy_setopt(curl,CURLOPT_VERBOSE,1);

}

UploadFile_FTP(remoetpath,local path)
{
    
    FILE *hd_src;
    struct stat file_info;

 char *UPLOAD_FILE_AS=new char[255];

 strncpy(UPLOAD_FILE_AS,remotePathName,strlen(remotePathName));

   struct curl_slist *headerlist=NULL;

   char *buf_1=new char [255];

   if(curl) {
    headerlist = curl_slist_append(headerlist, buf_1);
   // headerlist = curl_slist_append(headerlist, buf_2);
    curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
// curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
// curl_easy_setopt(curl, CURLOPT_INFILE,&file_info);
     curl_easy_setopt(curl, CURLOPT_UPLOAD,1);
     curl_easy_setopt(curl, CURLOPT_INFILESIZE,
                      (curl_off_t)file_info.st_size);
 
curl_easy_setopt(curl,CURLOPT_URL,);------------------------------->what
should this line be () or is there any other way i can send my file
     curl_easy_setopt(curl, CURLOPT_PREQUOTE, headerlist);
     curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
    res = curl_easy_perform(curl);
}

I create a object of type FTP_TEST

FTP_TEST ob1;
Ob1.Connect()-->This is working fine.
Ob1.Uploadfile_FTP (localpath,remotepath);

In Uploadfile_FTP I am Re-Using the Connection.Now I want to send the
file

Regards

Nagarajan

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Friday, June 20, 2008 2:15 AM
To: libcurl development
Subject: Re: Reg:FTP upload in libcurl

On Thu, 19 Jun 2008, nagarajan.sreenivasan_at_wipro.com wrote:

> I am Establishing the conneciton in function called connect()

Using what libcurl version on what platform?

> how do i pass the file name to a old connection (old URL)

A connection has no "file name". What exactly are you trying to do?

> * Re-using existing connection! (#0) with host <Servername>
> * Connected to <Servername> (<Server IP> ) port 21 (#0)
> * Uploading to a URL without a file name!

This means your URL ends with a slash.

> * Uploaded unaligned file size (0 out of 13 bytes)

This means the upload failed.

> * URL using bad/illegal format or missing URL

Now this is funny, but I figure this is because your URL contains some
funny letter or something.

Perhaps you better show us exactly what your code is doing...

--
  / daniel.haxx.se
Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com
Received on 2008-06-20