I have this code I wanted to call me at ftp
. By the browser I can, but by the code tells me that it can not log in.
Follow the code, I hid the data:
$ftp_server = "" ;
$ftp_user_name = "" ;
$ftp_user_pass = "" ;
$depth = 10;
$conn_id = ftp_connect($ftp_server) ;
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (!$login_result) { die("Couldn't log in to FTP account."); }
$dir = array(".");
$a = count($dir);
$i = 0;
while (($a != $b) && ($i < $depth)) {
$i++;
$a = count($dir) ;
foreach ($dir as $d) {
$ftp_dir = $d."/" ;
$newdir = ftp_nlist($conn_id, $ftp_dir);
foreach ($newdir as $key => $x) {
if ((strpos($x,".")) || (strpos($x,".") === 0)) { unset($newdir[$key]); }
elseif (!in_array($x,$dir)) { $dir[] = $x ; }
}
}
$b = count($dir) ;
}
print_r($dir) ;
ftp_close($conn_id);
?>