What is the best practice for listing ftp files from a remote server?
1) Using the ftp_connect () function
<?php
$conn = ftp_connect($ftp_server);
$login = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
$content = ftp_nlist($conn, ".");
var_dump($content);
?>
or
2) Using scandir () and then print the list of files with print_r ()
<?php
$path = "ftp://login:password@ftpserver";
$files = scandir($path);
print_r($files);
?>
Both methods output an array with ftp directories / files.
source
share