PHP FTP List Files

I am new to PHP FTP functions. I have a directory in my FTP location called documents. I need to get folders / files in another directory. So basically:

root / documents / Ryan-Hart / & -all-files / folders-here

So how can I show and link them to PHP. I 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 it goes to the array. How can I drop the name (plus extension) of a file and a link to them?

+4
source share
1 answer

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>'; } 
+7
source

Source: https://habr.com/ru/post/1342435/


All Articles