prueba esto, con el siguiente código obtienes un array con las carpetas y archivos de un directorio FTP
Código PHP:
Ver original<?php
// establecer una conexión básica
// iniciar sesión con nombre de usuario y contraseña
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// obtener la lista de archivos de /
// cerrar la conexión ftp
?>
Luego, una vez tengas el array puedes parsearlo con el siguiente código:
Código PHP:
Ver original<?php
// here the magic begins!
$arraypointer = &$structure;
foreach ($rawfiles as $rawfile) {
if ($rawfile[0] == '/') {
$arraypointer = &$structure;
foreach ($paths as $path) {
foreach ($arraypointer as $i => $file) {
if ($file['text'] == $path) {
$arraypointer = &$arraypointer[ $i ]['children'];
break;
}
}
}
} elseif(!empty($rawfile)) { 'text' => $info[8],
'isDir' => $info[0]{0} == 'd',
'size' => byteconvert($info[4]),
'chmod' => chmodnum($info[0]),
'date' => strtotime($info[6] . ' ' . $info[5] . ' ' . $info[7]), 'raw' => $info
// the 'children' attribut is automatically added if the folder contains at least one file
);
}
}
// in $structure is all the data
// little helper functions
function byteconvert($bytes) {
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); return sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) ); }
function chmodnum($chmod) {
$trans = array('-' => '0', 'r' => '4', 'w' => '2', 'x' => '1'); }
?>
Así, tendrás un array multidimensional ($structure) que contendrá toda la información de cada archivo y carpeta.
Todo el código está sacado de manual oficial de PHP, no es mío
![Silbar](http://static.forosdelweb.com/fdwtheme/images/smilies/silbar.gif)
Te dejo el enlace para que le eches un vistazo:
http://www.php.net/manual/es/function.ftp-rawlist.php