I've been bashing my head against a problem with PHP's FTP commands for some time now. Consider the following source code (host, login, PW info stripped out):
====
<?php
// Display raw contents of a directory
$hostname="STRIPPED";
$dirname="/maps/UTFILES/UTDmmaps";
// set up basic connection
$conn_id = ftp_connect($hostname);
// login with username and password
$login_result = ftp_login($conn_id, "STRIPPED", "STRIPPED");
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed! <p>";
die;
}
$foo=ftp_chdir($conn_id,$dirname);
$curr_dir=ftp_pwd($conn_id);
echo "My current directory is $curr_dir.<p>\n";
$dirlisting=ftp_rawlist($conn_id,"");
for ($i=0;$i<count($dirlisting);$i++) {
$data=$dirlisting[$i];
echo "$data <br>\n";
}
?>
====
Essentially, what this does is print out a raw FTP directory listing for the specified $hostname and $dirname.
I am using this code to get raw listings from a certain FTP server (running WarFTPD 1.65). What baffles me is that the code works on some of the directories, but not all of them.
I am echoing the "My current directory is" line to verify that the directory name I've entered is correct and that I have successfully navigated to it with ftp_chdir. That part of the code always works fine regardless of what directory I point to. The line that is choking within certain directories is:
$dirlisting=ftp_rawlist($conn_id,"");
This line causes the server to time out when I am looking at the problem directories.
I can access the file lists from the "problem directories" just fine using the host/login/pw information in a normal FTP client. But there is clearly something about those directories that PHP really doesn't like. And it isn't the number of files in those directories (the biggest directory in the system works fine).
Any suggestions would be very greatly appreciated ... this is slowly driving me nuts. Thanks.