I am new to the FTP feature of PHP. I have a dire开发者_如何学Goctory within my FTP location called documents. I need to get the folders/files within another directory. So like this basically:
root/documents/Ryan-Hart/ <-all-files/folders-here
So how can I show and link to these from PHP. I have tried this:
$name = "Ryan-Hart";
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
print_r(ftp_nlist($conn_id,"/documents/$name"));
But that comes out in array. How can a echo out the name (plus extension) of file and link to them?
Are you looking for something like that?
$arr= ftp_nlist($conn_id,"/documents/$name");
foreach ($arr as $value)
{
echo '<a href="'.$value.'">'.basename($value).'</a>';
}
精彩评论