I have the following code that connects to an ftp and back a list. But I can not get him to mount a Table with this list. Does anyone know how to do it?
$ftp_server = "ftp.site.com.br";
$ftp_user = "USER_FTP";
$ftp_pass = "SENHA_FTP";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "<br>$ftp_server";
} else {
echo "Couldn't connect as $ftp_user\n";
}
ftp_pasv($conn_id, TRUE);
$dir = "/diretorio/";
function filecollect($dir,$filelist) {
global $conn_id; //Retorna FTP
$files = ftp_nlist($conn_id,$dir); //Retorna o Directory
foreach ($files as $file) {
$isfile = ftp_size($conn_id, $file);
if($isfile == "-1") { //É um arquivo ou diretorio?
$filelist = filecollect($dir.'/'.$file,$filelist,$num); //Se for diretório, faça "filecollect()"
}
else {
$filelist[(count($filelist)+1)] = $file; //Se não,adicione a uma arquivo para a lista
}
}
return $filelist;
}
$list = filecollect($dir,$filelist);
$list = implode("<br>$ftp_server", $list);
echo $list;
ftp_close($conn_id);
I know there are some flaws but the main thing is to turn this data into a table.
Right now, thanks for the help.