Intervention Image: Save image directly from an url with original file name and ext?

谁都会走 提交于 2019-12-03 02:29:38
F. johns

response() does not return the original filename like Salines was requesting. This should work

$path = 'https://i.stack.imgur.com/koFpQ.png';
$filename = basename($path);

Image::make($path)->save(public_path('images/' . $filename));
CDF

You can easily do it using the make(); and response(); methods. Check my code below.

Just keep in mind that allow_url_fopen must be enabled to fetch a remote image.

This will display my profile picture. If you are not using it with Laravel Framework, just replace return with echo.

$img = Image::make('https://i.stack.imgur.com/koFpQ.png');
header('Content-Type: image/png');
return $img->response();

Hope that helps and upvote my reply if useful ;)

If you need further help just ask.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!