Mon Jun 22 2020
Directory Contents
PHP Scripting836 views
File Name: php-directory-contents.php
<html>
<head>
<title>Listing the Contents of a Directory</title>
</head>
<body>
<ul>
<?php
/* Directory name */
$dirname = "test";
/* Open directory handle */
$dh = opendir( $dirname );
/* Read directory */
while(!is_bool($file = readdir($dh))) {
/* List all directory and files */
if(is_dir( "$dirname/$file" ))
echo "<li>".$file." <small>(directory)</small></li>";
else
echo "<li>".$file."</li>";
}
/* Close directory handle */
closedir($dh);
?>
</ul>
</body>
</html>
/* Output */
contact _form.php
.. (directory)
a.php
ligthbox.html
file upload (directory)
abc.php
autocomplete (directory)
imageflow.packed.css
time.php
. (directory)
compress img.php
Author:Geekboots