如何显示目录Laravel中的所有文件

时间:2018-01-12 03:48:15

标签: laravel

如何在视图中显示表单目录中的所有文件

This my files

1 个答案:

答案 0 :(得分:0)

使用存储外观

$directory = 'name of a directory';
            // relative to root config set in config/filesystems.php which 
             by default is "storage_path('app/public')" so the search 
             will be in this directory

$directories = Storage::directories($directory);
// Recursive...
$directories = Storage::allDirectories($directory);

然后你将列表作为数组传递给它 查看

 return view('view path',compact('directories'));