I am trying to get a count of files inside a folder in my CodeIgniter project, I did the following:
<?php
$fi = new FilesystemIterator(base_url().'uploads', FilesystemIterator::SKIP_DOTS);
printf("There were %d Files", iterator_count($fi));
?>
but this gives me the following error:
FilesystemIterator::__construct(http://localhost/drive/uploads):
failed to open dir: not implemented
can anyone please tell me what is wrong in here, thanks in advance
My Answer:
php
$folder_path = 'path/to/folder';
$file_count = count(glob($folder_path . '/*'));
echo "Number of files in folder: " . $file_count;
Make sure to replace `'path/to/folder'` with the actual path to the folder you want to count the files in.
Rate this post
5 of 5 based on 8461 votesComments