Hi, I was wondering if it was possible to "get" how many files there are in a folder?
For example:
There will be 59 files in one directory. Then the php code would say:
There are 59 tutorials. View
Where the View is I want to put in a link, that goes to that folder.
Thanks!
Okay, it works. I was testing it on my home server before I uploaded it onto Frihost. I guess Xampp doesn't have Save Mode Off?
this script will list all files in a directory and can even list directories if u want to..........
<?php
// This is the directory to list files for.
$theDirectory = ".";
// Do you want to show directories? change to false to hide directories.
$listDirectories = true;
if(is_dir($theDirectory))
{
echo "<table><tr><td>Name</td><td>Type</td><td>Size</td></tr>";
$dir = opendir($theDirectory);
while(false !== ($file = readdir($dir)))
{
$type = filetype($theDirectory ."/". $file);
if($listDirectories || $type != "dir")
{
echo "<tr><td>" . $file . "</td>";
echo "<td>" . $type . "</td>";
echo "<td>";
if($type == "file")
echo filesize($file);
echo "</td></tr>";
}
}
closedir($dir);
echo "</table>";
}
else
{
echo $theDirectory . " is not a directory";
}
?>