php - Can't display the uploaded image laravel
I'm trying to upload image to display it in view, but when I try to display it, it doesn't show on image section of my view.
I already have symlink, and it works. I can see my uploaded image in 'public/storage/images' path. It also shows up on 'storage\app\public\images' path.
My code to display the image
@if(filled($book->image))
<img src="{{asset($book->image)}}" style="width: 8%;height:8%">
My code for the image upload
if ($request->hasFile('book_image')) {
$book->image = $request->file('book_image')->storeAs('public/images', $request->id . '.' . $request->file('book_image')->getClientOriginalExtension());
}
Answer
Solution:
Use src="{{ url('/images/'.$book->image) }}"
Answer
Solution:
if you want to get the image url in blade then you can use url helper like img src="{{ url('storage/app/public/images/'.$filename) }}"
or elsewhere like
storage_path('/app/public/images/' . $filename)
Answer
Solution:
Rewrite your code like this
<img src="{{asset('images/'.$book->image)}}" style="width:8%; height:8%">
This should work if you already run storage:link
in your command line