php - 无法将图像数据写入路径 - 干预图像
问题描述
我正在尝试在我的 laravel 项目中使用干预包来调整图像的大小。我可以使用 Storage 门面存储图像,但是当我使用 Image 类存储它们时,它会引发以下错误。
无法将图像数据写入路径 (/var/www/commerce/storage/featureds/2-1537128615.jpg)
if ($request->has("featured_img")) {
$file_path = $request->get("featured_img");
$exp = explode("/",$file_path);
$filename = $exp[1];
$featured_path = "featureds/".$filename;
\Storage::copy($request->get("featured_img"), $featured_path);
\Image::make(\Storage::get($featured_path))->fit(400, 300)->save(storage_path($featured_path));
$product->media()->where("type", "featured")->update(["path" => $featured_path]);
}
我怎样才能解决这个问题 ?感谢您的所有帮助
解决方案
存储中有特色目录吗?
如果不是,则使用mkdir创建目录,因为 Intervention 不会自动创建目录。
推荐阅读
- python - 将 `tf.constant` 与整数进行比较
- c# - mdb文件数据插入增加mdb大小
- r - Concatenate data.frame character columns based on column index stored as a vector in R w/ dplyr mutate()?
- python - Python将图像堆叠成立方体
- c# - 使用 RegEx 在文本 c# 中查找 100$
- python - pxssh 在 slurm 集群中的计算节点之间不起作用
- javascript - 十六进制颜色代码如何转换为波长?
- seal - SEAL 库中的模数切换
- linux - Linux Sed 搜索特殊字符
- python-3.x - 如何从日期时间转换为每月的工作日常量?