Return Response Image in Laravel 7
3
I'm trying to create a mini random
image generator, as a start I've tried :
Route::get('/img/UoJb9wl.png','Image@random');
All I did is to return this
return '<img src="/assets/fe/img/welcome.jpeg" alt="Smiley face" width="200">';
Then, I tested on the live site :
I see the image loaded if I go to the URL
https://www.bunlongheng.com/img/UoJb9wl.png
If I imported on a site like JSFiddle like this
<img src="https://www.bunlongheng.com/img/UoJb9wl.png">
I can't see it.
Why ?
Edit
Try #2
return env('APP_URL').'/assets/fe/img/welcome.jpeg';
I return image path now
But I still nothing rendering in my JSFiddle still
<img src="https://www.bunlongheng.com/img/UoJb9wl.png">
php laravel image laravel-5 laravel-7
header('Content-Type: image/png');
your header's content_type may be not a image type, what's your controller code? – Espresso Apr 14 at 21:32return response($img_path)->header('Content-type','image/png');
– Espresso Apr 14 at 21:34https://www.bunlongheng.com/img/UoJb9wl.png
Result : i.imgur.com/PZgNRyD.png – cyb3rZ Apr 15 at 0:43