Anyone know of any scripts to show on a page how many files are in a certain folder?

Anyone know of any scripts to show on a page how many files are in a certain folder?
What do you mean, as in cPanel or just an index?
just a folder, for example i wanted to display how many files had been uploded into the uploads folder
Here's a code from my TehUpload core.
Usage:PHP Code:/**
* Numbers files in a directory
*
* @param string $dir
* @param boolean $recursive
* @param integer $counter
* @return integer
*/
public function numFiles ( $dir, $recursive = false, $counter = 0 )
{
static $counter;
if ( is_dir( $dir ) ) {
if ( $dh = opendir( $dir ) ) {
while ( ( $file = readdir( $dh ) ) !== false ) {
if ( $file != "." && $file != ".." ) {
$counter = ( is_dir( $dir . "/" . $file ) ) ? num_files( $dir . "/" . $file, $recursive, $counter ) : $counter + 1;
}
}
closedir( $dh );
}
}
return $counter;
}
That is if it is in a class.PHP Code:echo $core->numFiles('images/');
You'll need to remove public for it to work out of PHP5 and a class.PHP Code:echo numFiles('images/');
Last edited by Dentafrice; 19-06-2008 at 01:09 PM.
still havent found any that actually work
That works perfect..
didnt for me
did it error?
Want to hide these adverts? Register an account for free!