Posted by Brian on 10/13/84 11:26
Hi all
Below is a bit of code that puts the file list of a dir
into an array which I use later.
2 questions.......
1) how do I get the loop to only show files and not other directories?
2) Quite sure this can't be done other wise hacking would be so easy,
but is it possible to read the dir on a different server, and get the file
list
in date order of creation?
Thanks
Brian
if ($handle = opendir($path)) {
$thefiles = array();
while (false !== ($file = readdir($handle))) {
$ext = strrchr( $file, '.' );
if ( $ext == '.zip' || $ext == '.csv' || $ext == '.txt' || $ext ==
'.doc' || $ext == '.jpg' || $ext == '.bmp'
|| $ext == '.gif' || $ext == '.php' || $ext == '.htm' || $ext ==
'.html' || $file !== 'fileviewer.php') {
$thefiles[] = $file;
}
}
closedir($handle);
rsort($thefiles);
reset($thefiles);
}
Navigation:
[Reply to this message]
|