0

Hi!

I have to upload a file to a separate server and I was given access to its ftp. But to be able to access the ftp, I need ftp over ssl explicit. I tried to use curl to connect to ftp. I was able to pass through the 220 that appears just like when connecting using filezilla, but I cannot seem to login. here's the code I'm using:

        error_reporting(E_ALL);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "ftp.example.com:21");

        curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
        curl_setopt($curl, CURLOPT_USERPWD, "user:password");
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); 
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); 
        curl_setopt($curl, CURLOPT_FTP_SSL, CURLOPT_FTPSSLAUTH);
        curl_setopt($curl, CURLOPT_SSLVERSION, 3);

        curl_setopt($curl, CURLOPT_TIMEOUT, 30);
        curl_setopt($curl, CURLOPT_FTP_USE_EPSV, 1);

        $result = curl_exec($curl);
        $error_no = curl_errno($curl);


        $tuData = curl_exec($curl); 
        if(!curl_errno($curl)){ 
          $info = curl_getinfo($curl); 
          echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; 
        } else { 
          echo 'Curl error: ' . curl_error($curl); 
        } 

But this results to:
220- ...
220- ...
220 ...
530 Please login with USER and PASS 504 unknown security mechanism 504 unknown host

Took 0.462022 seconds to send a request to HTTP://ftp.example.com:21

Tried to access this using filezilla and I was able to.
Any ideas? Thanks :)

Edited by pritaeas: Removed real URL from error message.

2
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by cmsc
0

I tried adding the path to file, but still same the error: Server denied you to change to the given directory appeared.

Edited by cmsc

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.