Yes, that's correct: you should use asset('storage/' . $employer->logo) to display files that you've stored via Laravel's Storage facade, specifically when you're saving files to the storage/app/public directory.
Here’s why:
By default, files saved with:
$request->file('logo')->store('logos', 'public');
…are put in storage/app/public/logos. However, your web server cannot directly access anything in storage/app. That's why you need a symbolic link from public/storage to storage/app/public. This is what the php artisan storage:link command does.
So to show images in the browser, you must reference them as:
asset('storage/' . $employer->logo)
This means if $employer->logo is logos/company.png, the full browser path would be:
/storage/logos/company.png
The asset($employer->logo) approach would look for /logos/company.png in public/logos, which won't work unless you manually move files there (not recommended).
Summary of Steps:
- Run:
php artisan storage:link - Store files using the
publicdisk:$filePath = $request->file('logo')->store('logos', 'public'); - Display them using:
<img src="{{ asset('storage/' . $employer->logo) }}">
If you follow those steps, your images should display correctly.