我有递归迭代器概述,我得到了所有文件,但也得到了所有目录。我只想概述文件。 我有以下代码:
<?php
$root = '/xampp/htdocs/systeembeheer/Storage/download/';
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
$paths = array($root);
foreach ($iter as $path => $dir) {
if ($dir->isDir()) {
$paths[] = $path;
}
}
?>
答案 0 :(得分:3)
您可以使用文件(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