Reputation: 65
please I have this problem,
I want to upload and display uploaded images in my laravel application.
Here is the code for controller
//testing uploads
$extension = $request->file('test_img')->extension();
$path = $request->file('test_img')->storeAs(
'public/id', 'test.'.$extension
);
The image uploads successfully to storage/public/id/test.jpg
Now I have ran the artisan storage command
php artisan storage:link
I want to display this image in my controller like this,
<img src="{{ asset('public/id/test.jpg') }}" alt="image">
However this does not load the image.
also, after upload if i do a die dump dd($path);
it will return public/id/test.jpg
but when i visit https://test-project.local/public/id/test.jpg
it will return a 404.
I am using laragon for local apache, laravel 9 and php 8
Modified
it works now with this. {{ asset(‘storage/id/test.jpg’) }}
Upvotes: 0
Views: 234
Reputation: 1182
You don't need public
in your asset
helper. Just try with:
asset('id/test.jpg');
Upvotes: 2