
Just place the following piece of code in a file and save it as “index.php” and transfer it into the directory for which you need to create directory
[php]
<?php
if ($handle = opendir(‘.’)) {
$kb = 1024;
$dirlist .= ‘<table border=0><tr><th>File Name</th><th>File Size</th></tr>’;
while (false !== ($file = readdir($handle)))
{
if ($file != “.” && $file != “..” && $file != “index.php”)
{
$dirlist .= ‘<tr><td><a href=”‘.$file.'”>’.$file.'</a></td>’;
$sizeinbits = filesize($file);
$sizeinkb = $sizeinbits / $kb;
$dirlist .= ‘<td>’.$sizeinkb.’ Kb</td></tr>’;
}
}
closedir($handle);
$dirlist .= ‘</table>’;
}
?>
<P>List of files:</p>
<P><?php echo $dirlist ?></p>[/php]
Once you place this index.php file by default this page opens up and shows the list of files in that particular and in addition to this you can customize the way it can be displayed by styling it using CSS.
Hope this helps you and feel free to comment if you have any queries.