Use PHP to count number of files in a directory
Here's a simple bit of PHP code to get the total number of files in a directory using the glob() and count() functions:
$num_files = count(glob($_SERVER['DOCUMENT_ROOT'].'/path/to/directory/*'));
Or here's how to only count files with a .jpg extension:
$num_files = count(glob($_SERVER['DOCUMENT_ROOT'].'/path/to/directory/*.jpg'));
$num_files = count(glob($_SERVER['DOCUMENT_ROOT'].'/path/to/directory/*'));
Or here's how to only count files with a .jpg extension:
$num_files = count(glob($_SERVER['DOCUMENT_ROOT'].'/path/to/directory/*.jpg'));




