View Full Version : Displaying number of files in a remote folder
Anyone know of any scripts to show on a page how many files are in a certain folder?
Excellent
19-06-2008, 12:52 PM
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
Dentafrice
19-06-2008, 12:55 PM
Here's a code from my TehUpload core.
/**
* 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;
}
Usage:
echo $core->numFiles('images/');
That is if it is in a class.
echo numFiles('images/');
You'll need to remove public for it to work out of PHP5 and a class.
still havent found any that actually work
Dentafrice
24-06-2008, 03:14 PM
That works perfect..
Dentafrice
24-06-2008, 03:29 PM
did it error?
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.