Jur Hillebrink Jur Hillebrink - 2 months ago 7x
PHP Question

Recursive overview files PHP/Laravel

I have the recursive iterator overview, I get all the files but also all the directory's. I want only a overview of the files.
I have this code below:


$root = '/xampp/htdocs/systeembeheer/Storage/download/';

$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"

$paths = array($root);
foreach ($iter as $path => $dir) {
if ($dir->isDir()) {
$paths[] = $path;



You can use File (Illuminate\Support\Facades\File) facade:

    foreach (File::allFiles($root) as $file) {
        // $file->getFilename()

API: https://laravel.com/api/5.2/Illuminate/Contracts/Filesystem/Filesystem.html