andyd34
1
I am trying to get the number of files in a directory.
I have the following code
[php]
if ($handle = opendir(’…/uploads/0000004/’)) {
while (false !== ($file = readdir($handle))) {
if ($file != “.” && $file != “…”) {
$files = array($file);
echo “$file
n”;
}
}
closedir($handle);
}
echo count($files);
[/php]
but its just returning 1
anyone have any suggestions
Q1712
2
[php]$files[] = $file;[/php]
andyd34
3
Thanks for that, works ok now
[php]
if ($handle = opendir(’…/uploads/0000004/’)) {
while (false !== ($file = readdir($handle))) {
if ($file != “.” && $file != “…”) {
$files[] = $file;
}
}
closedir($handle);
}
if(count($files) < 6 ) { echo “More Files”; } else { echo “enough is enough”; }
[/php]
andyd34
4
Just a quicky, I tried the scandir function and kept on getting the following error
[i][b]Call to a member function on a non-object [/b][/i]