Ok, this one was a kinda fun to work on. Haven't really messed with FTP a whole lot. Here's something to get you started. The files function just gets a list of the current directory. The display_list function is where we get recursive on the directories. Test the files in the list, if we can change directory to them, then get the list there. cdup to return to our normal directory. Now, this isn't rock solid code, and is barely tested, but should give you a good foundation to start from.
<?php
error_reporting(E_ALL);
$ip = "";
$usr = "";
$pass = "";
$path = "public_html";
$conn_id = ftp_connect($ip);
$login_result = ftp_login($conn_id,$usr,$pass);
$list = files($path,$conn_id);
display_list($list,$conn_id);
ftp_close($conn_id);
function files($dir,$conn) {
@ftp_chdir($conn,$dir);
$list = array();
$list = ftp_nlist($conn,"");
return $list;
}
function display_list($list,$conn) {
foreach($list as $file) {
if(@ftp_chdir($conn,$file)) {
echo "<dl><dt><===".$file."===></dt>\n";
$list = files("",$conn);
echo "<dd>\n";
display_list($list,$conn);
echo "</dd>\n";
ftp_cdup($conn);
echo "</dl>\n";
}
else {
echo "<b>".$file."</b><br />\n";
}
}
}
?>