Laravel干预 - 无法从给定的二进制数据中启动
我正在我的一个项目中使用“干预/图像”:“^2.5”
。除了要检索图像的代码的一部分外,它的运行良好。
我一直无法从给定的二进制数据错误中启动错误,但我无法弄清楚原因。
该文件存在,但我无法弄清楚。
我的代码如下;
$path = '/image-storage/492/1/testimage.jpg';
$file = Storage::get($path);
ob_end_clean();
return Image::make($file)->response();
以下是我的filesystem.php
本地配置
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
I am using "intervention/image": "^2.5"
in one of my projects. It is working well except for one part of the code where im retrieving an image.
I keep getting a Unable to init from given binary data
error and i cant figure out why.
The file exists but i cant figure it out.
My code is as follows;
$path = '/image-storage/492/1/testimage.jpg';
$file = Storage::get($path);
ob_end_clean();
return Image::make($file)->response();
Below is my filesystem.php
config for local
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存储:: get($ path)返回文件内容作为字符串,可能不会将其施放为 image :: make()能够读取的有效二进制数据。
您可以通过将通往图像的路径传递到 make 方法
,也可以创建一个新的
Illuminate \ http \ file
实例,然后将其传递到 方法干预图像接受二进制数据或 splfileinfo 实例。
照明\ http \ file
扩展symfony \ component \ httpfoundation \ httpfoundation \ file \ file \ file \ file
\ splfileinfo
。“干预图像” - 阅读图像
Storage::get($path) returns file contents as a string which may not be cast to valid binary data for Image::make() to be able to read.
You can try by passing the path to the image to the make method
OR you can create a new
Illuminate\Http\File
instance and then pass it to the make methodIntervention image accepts binary data or SplFileInfo instance.
Illuminate\Http\File
extendsSymfony\Component\HttpFoundation\File\File
which extends\SplFileInfo
.Intervention Image - Reading Images