File count
Moderator: General Moderators
File count
How can I count how many files are in a directory excluding "." and ".."?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
The code below always produces 1 no matter how many are in the folder.
Code: Select all
$dir = opendir("/home/wiles63/public_html/jobstatus/files/17/");
$file_count = count(readdir($dir));
echo $file_count;
if($file_count == "0") {
echo "<big><font color=\"#FF0000\"><b>No files have been attached!</b></font></big>";
}Code: Select all
<?php
echo count( glob( '/home/wiles63/public_html/jobstatus/files/17/*' ) );
?>