[英]Intervention\Image\Exception\NotWritableException: Can't write image data to path
I tried to save my decoded base64 into storage folder but I got this error message;我试图将解码后的 base64 保存到存储文件夹中,但收到此错误消息; even the permission storage and all subdirectories is
775
.甚至权限存储和所有子目录都是
775
。
Intervention\Image\Exception\NotWritableException: Can't write image data to path
My code我的代码
$image = $request->image;
$image = str_replace('data:image/png;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imageName = str_random(32).'.'.'png';
\Image::make(base64_decode($image))>save('avatar/'.$imageName);
Storage path: /storage/app/public/avatar
存储路径:
/storage/app/public/avatar
I see that you missed dash symbol before save method, it should be:我看到您在保存方法之前错过了破折号,它应该是:
\Image::make(base64_decode($image))->save('avatar/'.$imageName);
Also, you can check if directory exists, if there is no such directory then create it:另外,您可以检查目录是否存在,如果没有这样的目录,则创建它:
if (!File::isDirectory($path)) {
File::makeDirectory($path, 0775, true);
}
Don't forget to include File facade at the top:不要忘记在顶部包含 File facade:
use Illuminate\Support\Facades\File;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.