Reputation: 375
I have uploaded images in storage folder. Now I want to retrieve the images in the view. I am working local environment right now. <img src={{ Storage::disk('local')->url($image->path) }}>
doesn't to work. What am I missing?
Upvotes: 0
Views: 762
Reputation: 2523
Why not make a function that receives either a name or a an ID of an model or whatever you have and return the image according to some logic? For example :
// Controller public function getImage(Request $request){ $filename = $request->filename; $file = Storage::disk('local')->get($filename); return response($file)->withHeaders(['Content-Type' => "image/png"]); } // Route Route::get('/getThisImage/{filename}',[ 'uses'=>'HomeController@getImage', 'as'=>'getImage' ]); // Example of calling it in blade <img src="{{route('getImage')}}/{{$image->path}}">
Upvotes: 0
Reputation: 4114
First, make sure that you have setup symlink properly between public and storage/app/public directories. You can do this by using this command:
php artisan storage:link
For more info please have a look: https://laravel.com/docs/5.3/filesystem#configuration
In view, you can display an image like this:
<img src="{{ asset($image->path) }}" />
Also, make sure that you storing image path correctly in the database.
Upvotes: 2