note 43688 added to function.readdir
| From: | g dot ionescu at gmail dot com | Date: | Wed, 30 Jun 2004 10:10:44 +0000 |
| Subject: | note 43688 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72165@lists.php.net to get a copy of this message | ||
Simple recursive directory browsing:
<?php
function fdirlist( $ppath )
{
chdir($ppath); $cdir=getcwd();
print '<font
color="red"><b>'.$cdir.'</b></font><br>';
if ($handle = opendir($ppath)) {
while ( $file = readdir($handle) ) /* directory listing first */
{
$ffile=$cdir.'/'.$file;
if ( is_dir($ffile) )
{ echo '<a
href="'.$_SERVER['PHP_SELF'].'?calea='.$ffile.'/"><font
color="blue"><b>'.strtoupper($file).'</a></b></font>
<br>'; }
}
}
closedir($handle);
if ($handle = opendir($ppath)) /* files list */
{
while ( $file = readdir($handle) )
{
$ffile=$cdir.'/'.$file;
if ( is_file($ffile) )
{ echo '<font
color="blue">'.strtolower($file).'</font><br>'; }
}
}
closedir($handle);
}
$ppath=getcwd();
if ( !is_null($_REQUEST['calea']) )
{
$ppath=$_REQUEST['calea'];
}
fdirlist($ppath);
?>
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43688
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43688&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43688&report=yes
Search -- http://master.php.net/manage/user-notes.php