干预图像:直接从具有原始文件名和扩展名的URL中保存图像? [英] Intervention Image: Save image directly from an url with original file name and ext?

查看:57
本文介绍了干预图像:直接从具有原始文件名和扩展名的URL中保存图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从远程服务器拍摄图像时如何获取文件名?以及如何保存原始大小和文件名?

How to get the filename, when taking image from a remote server? And how to save with original size and filename?

// Take remote image
$img = Image::make('http://image.info/demo.jpg');
// how to save in the img/original/demo.jpg
$img->save(????);

我使用干预,( http://image.intervention.io/api/make )来构建CakePHP 3图像行为,我想提供一种从远程服务器轻松上传的方法,并保留原始图像作为以后处理的来源.

I use Intervention, (http://image.intervention.io/api/make) to build CakePHP 3 image Behavior, I want to provide an easy uploading from remote servers, and keep the original image as a source for future manipulation.

编辑

我问,是否有干预图像方法,当从远程服务器获取文件时,该方法返回文件名.我知道php copy(),basename(),我也可以使用CakePHP File实用程序,但是它给了我对远程文件的重复请求.

I ask, is there the Intervention Image method that returns the name of the file, when taken from the remote server. I know php copy(), basename(), I can also use the CakePHP File utilities, but it gives me the duplicate request on remote file.

推荐答案

response()不会像Salines请求的那样返回原始文件名.这应该可以工作

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));

这篇关于干预图像:直接从具有原始文件名和扩展名的URL中保存图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆