Laravel – Getting only the filename in laravel 5

filenames, laravel, path

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.

Best Solution

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);