Reputation: 603
I'm trying to get the amount of all uploaded files of today in a directory with php. The directory is called 's', and all files in it are jpg and/or png files.
Thank you.
Upvotes: 0
Views: 146
Reputation: 329
you could do something like this
$dir = 's';
$i = 0;
//here list of files of your directory with extension (jpg, jpeg, png) case insenstive
if (is_dir($dir)) {
$files = glob($dir . '/*.{jpg,JPG,jpeg,JPEG,png,PNG}', GLOB_BRACE);
$currentDate = date("F d Y");
if (!empty($files) && is_array($files)) {
foreach ($files as $f) {
if (date("F d Y", filemtime($f)) == $currentDate) {
$i++;
}
}
}
}
return $i;
Upvotes: 1