26.7 C
New York
Wednesday, August 10, 2022

How to count number of files in directory PHP?

- Advertisement -





If you are working on code php and you require to count number of files, images, zip file, rar files, etc in the given folder path, then you can count using glob() and count() of php. So, let’s see this bellow example and learn how it done.

$folderPath = "upload/";

$countFile = 0;

$totalFiles = glob($folderPath . "*");

if ($totalFiles){

$countFile = count($totalFiles);

}

print_r($countFile);

- Advertisement -

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles