-1

I have to connect to a FTPES server to retrieve data. Connecting and logging in works just fine, but my call with ftp_rawlist always fails and returns "false".

I am using this code for debugging purposes:

$ftp = ftp_ssl_connect($ftp_host);
if (ftp_login($ftp, $ftp_user, $ftp_pass)) {
    $p = ftp_pasv($ftp, true);
    var_dump($p);

    $r = ftp_rawlist($ftp, '/', true);
    var_dump($r);
} else {
    echo 'Could not login';
}

$p is always true, $r always false.

When I connect to the server through Filezilla everything works fine and I can list directory content and more.

Update #1: Tried to not only list '/' but various subfolders on the server, they all fail through the script.

Update #2: Also tried to use ftp_raw with the commands to get a list, but the LIST command runs for some time and then does not return any result at all. But HELP lists LIST as a valid command for the server... Strange...

Update #3: I tried phpseclib now, but while I can connect, I can't login with the user/password combination. Support from the maintainer of the FTPES server is not happening ("works fine for $somebody else..."), so I need to figure this out another way... :-)

flomei
  • 860
  • 1
  • 11
  • 36

2 Answers2

0

To come to an end with this: As the deadline for this project came closer a solution had to be found. And although this is no real answer in the sense of a question, I'd like to show what I have done to have this fixed. Maybe someone stumbles upon this through googling.

Next to the things mentioned in the OP, I also tried connecting to FTPS using PHP and certificate as auth which didn't work either. As nothing works as it is supposed to, I wonder if the FTPS server is really configured correctly after all.

The people who run the server told me that everything is fine and their CLI CURL-call works fine for them, so they have no need to further investigate issues.

As a result of this I set up a sandbox account on a server which has shell_exec() enabled. There is now a script running which gets a file listing via CURL and then downloads the files via CURL with the commands provided by the server provider. That server can be accessed through normal SFTP and therefore acts as a "Proxy FTP" which regularly mirrors the remote FTPS server file structure.

Although I find this "solution" quite "hacky" it seems to run robust, stable and fast for the moment. We will therefore be able to have the operation running this way in this year (it only runs around three months before christmas) and will have a look into it in the new year and develop a more stable solution.

Maybe the server guys are also less stressed then and willing to help... ;-)

flomei
  • 860
  • 1
  • 11
  • 36
0

Add the following call to ftp_set_option() in a line before the call to ftp_pasv

ftp_set_option($ftp, FTP_USEPASVADDRESS, false);
ftp_pasv($ftp, true);
Nathan Basanese
  • 8,475
  • 10
  • 37
  • 66
Neil
  • 11