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

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

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.

EDIT

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请求的那样返回原始文件名.这应该行得通

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

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

Laravel相关问答推荐

为什么Laravel在API请求时返回BadMethodCallException?

根据路径的开头重定向

如何通过 Eloquent 获取单个集合中每位教师的学生人数

Laravel 9 上的数组差异助手

给定的角色或权限应该使用 guard `` 而不是 `web`. -Laravel

错误try 访问 null 类型值的数组偏移量laravel 5.8.26 Php 7.4.2

Laravel 5.7 判断Electron邮件是否经过验证

Laravel 4 如何监听模型事件?

Laravel Eloquent Pluck 不丢失密钥

Laravel 5 文件下载:stream() 或 download()

SQLSTATE [42000]:语法错误或访问冲突:1066 Not unique table/alias on relationship

Laravel 5:完整性约束违规:1452 无法添加或更新子行:外键约束失败

Laravel 分页方法不适用于 map 集合?

Laravel 无法创建根目录

Laravel 的 toSql() 方法是否会屏蔽 id? (列值被问号替换)

将 Laravel 集合附加到另一个集合

如何在 vs 代码中自动导入 laravel 类

如何在 Laravel 中 Refresh刷新用户对象?

如何在 Eloquent Orm 中实现自引用(parent_id)模型

复合唯一密钥验证 - laravel