QuadVods
05-21-2006, 01:24 PM
Hi,
I'm using this script to count the number of files in a directory (e.g. I want to display: '10 Files hosted')
The problem is that this code is returning '0' as the count, which is wrong.
The index page in the root will have the counter (www.domain.com (http://www.domain.com))
the directory with the files in is www.domain.com/1 (http://www.domain.com/1)
//get path of directory containing this script
$dir = $_SERVER['DOCUMENT_ROOT'].dirname("/1/");
//open a handle to the directory
$handle = opendir($dir);
//intitialize our counter
$count = 0;
//loop through the directory
while (false !== ($file = readdir($handle))) {
//evaluate each entry, removing the . & .. entries
if (is_file($file) && $file !== '.' && $file !== '..') {
$count++;
}
}
echo $count;
Any help would be much appreciated!
I'm using this script to count the number of files in a directory (e.g. I want to display: '10 Files hosted')
The problem is that this code is returning '0' as the count, which is wrong.
The index page in the root will have the counter (www.domain.com (http://www.domain.com))
the directory with the files in is www.domain.com/1 (http://www.domain.com/1)
//get path of directory containing this script
$dir = $_SERVER['DOCUMENT_ROOT'].dirname("/1/");
//open a handle to the directory
$handle = opendir($dir);
//intitialize our counter
$count = 0;
//loop through the directory
while (false !== ($file = readdir($handle))) {
//evaluate each entry, removing the . & .. entries
if (is_file($file) && $file !== '.' && $file !== '..') {
$count++;
}
}
echo $count;
Any help would be much appreciated!
