Listing files in current directory
Posted: Sat Apr 03, 2004 9:58 pm
How do I obtain a list of files in any given directory? I would need to output them to a select list for someone to choose.... I found this code elsewhere on the forums but it wouldn't output anything at all
Code: Select all
<?php
function ListDirContents($align)
{
$dir_full = shell_exec("ls");
$dir_files = explode("\n", $dir_full);
for ($i=0; $i<count($dir_files); $i++) {
$count = $i+1;
?>
<div align="<?php echo $align; ?>">
<p><?php echo $count; ?>. <a href="http://studentcenter.compbrain.net/~pn/<?php echo $dir_filesї$i]; ?>"><?php echo $dir_filesї$i]; ?></a></p>
</div>
<?php
}
}
?>