Hyosoka Poipo Hyosoka Poipo - 1 year ago 236
PHP Question

How to display image from aws s3 in blade laravel 5.2

I have created a method for getting the data(image file) from aws S3 like this :

public static function getImage ($imagePath)
return Storage::disk('s3')->get($imagePath);
return 'No Image';

I'm sure that those image is exist on the aws, so there is no problem with that.
And then I use above method as the src in my blade view like this :


$myPath here already point to the specific file on aws for example : bucket/file.jgp. But when I run my webpage, this Html::Image gives a view like this :
enter image description here

What's going on here ? Why Html::image can't render my image file ? :(

Answer Source
{!!Html::image(<Your S3 bucket URL>.$myPath),'logo',['width'=>60,'height'=>55])!!}

You can save the S3 URL in a config file and use the config value instead of writing actual value everytime.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download