Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting only the filename in laravel 5

When i have a variable like:

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

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

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

In my view, the files displayed as:

/xampp/htdocs/systeembeheer/public/download/test.txt, but I want to see only test.txt.

like image 695
jurh Avatar asked Jul 14 '16 09:07

jurh


1 Answers

You have to use basename which returns trailing name component of path.

So in your view use something like

//$file is full path 
echo basename($file);
like image 105
KuKeC Avatar answered Oct 24 '22 22:10

KuKeC