仅获取laravel 5中的文件名

时间:2016-07-14 09:46:31

标签: laravel path filenames

当我有一个变量时:

$ storagePath =('/ xampp / htdocs / systeembeheer / public / download');

$files = File::allFiles($storagePath);

return View::make('documentatie.overzicht') ->with('files', $files); 

在我看来,文件显示为:

/xampp/htdocs/systeembeheer/public/download/test.txt,但我只希望看到test.txt

1 个答案:

答案 0 :(得分:7)

您必须使用basename返回路径的尾随名称组件。

因此,在您的视图中使用类似

的内容
//$file is full path 
echo basename($file);