Jur Hillebrink Jur Hillebrink - 1 year ago 104
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;


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download