Getting only the filename in laravel 5
15,233
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);
Author by
jurh
Updated on June 25, 2022Comments
-
jurh almost 2 years
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 onlytest.txt
. -
Ivandez about 3 yearsthanks a lot, it works with larave 8 and php 8