当我有一个像这样的变量时:
$ storagePath =('/ xampp / htdocs / systeembeheer / public / download');
$files = File::allFiles($storagePath);
return View::make('documentatie.overzicht') ->with('files', $files);
Run Code Online (Sandbox Code Playgroud)
在我看来,文件显示为:
/xampp/htdocs/systeembeheer/public/download/test.txt但是我只想看test.txt。
我有递归迭代器概述,我获得了所有文件以及所有目录的文件。我只想要文件的概述。我有下面的代码:
<?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;
}
}
?>
Run Code Online (Sandbox Code Playgroud)