2
I use Laravel 5.3 and I’m having this problem:
The Response content must be a string or Object implementing __toString(), "Object" Given,
when I try to use a route which returns an image of a particular user of my system, follows the code below.
Here is the action
of controller
that returns the image.
public function getImage($filename)
{
$file = Storage::disk('local')->get("/avatars/".$filename);
return new Response($file, 200);
}
Route
Route::get('getImage/{filename}', 'TeatcherController@getImage')
->name('get.image')
->middleware('auth');
Using the route to get the image
<img src="{{ url(route('get.image', ['filename' => $user->teatchers->photoName] )) }}" alt="{{$user->teatchers->photoName }}">