I am currently on a mac, when I use the command line client to connect to an ftp server it works and I see two folders Arkiv and Saxo, I see the same thing if I go in the browser.
In drupal I have a cron hook where I use the php ftp functions. I am of course using the same username, password as the two other cases here is a sample of the code
if (@ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
$listing = ftp_rawlist($conn_id, ".");
watchdog('ftp root current directory', ftp_pwd($conn_id),array(), WATCHDOG_WARNING);
watchdog('ftp root directory listing', print_r($listing,true),array(), WATCHDOG_WARNING);
watchdog('ftp root try to change directory',$dir,array(), WATCHDOG_WARNING);
$filecount = 0;
if (ftp_chdir($conn_id, $dir)) {
$contents = ftp_rawlist($conn_id, ".");
watchdog('inside contents', print_r($contents,true), array(), WATCHDOG_WARNING);
watchdog('inside contents and current folder', ftp_pwd($conn_id), array(), WATCHDOG_WARNING);
...
}}
the variable $dir is set to be the name of one of these folders I am expecting to see - in this case 'Arkiv', and this folder has a few hundred files in it when I look on the command line or in the browser.
The messages I receive back from this process are:
inside contents and current folder 09/09/2014 - 15:19 /Arkiv Anonymous (not verified)
inside contents 09/09/2014 - 15:19 Anonymous (not verified)
ftp root try to change directory 09/09/2014 - 15:18 Arkiv Anonymous (not verified)
ftp root directory listing 09/09/2014 - 15:18 Anonymous (not verified)
ftp root current directory 09/09/2014 - 15:18 / Anonymous (not verified)
I do not seem to be able to get any content back when I try to list the directory contents. I have tried both rawlist and nlist, and neither one gives me any content back, both in the root directoy where I should have the two subdirectories Arkiv and Saxo, and in the subdirectories themselves where there are a few hundred files (confirmed from command line and browser).
furthermore, if the output from $listing = ftp_rawlist($conn_id, "."); is empty, how can it be that when I do
if (ftp_chdir($conn_id, $dir)) { .. }
that it allows me through and
ftp_pwd($conn_id)
tells me I am in the '/Arkiv' folder?
The difference is caused by being inside of a virtual machine with NAT and various firewalls, in that situation should use ftp_pasv http://php.net/manual/en/function.ftp-pasv.php which I was, unfortunately I was calling it before the login, when the documentation specifies it should be called after the login.