Laravel - 干预图像 - 图像来源不可读

3

我想使用Intervention Image包调整图片大小,但是在尝试时出现了以下错误:

Intervention \ Image \ Exception \ NotReadableException
图像源不可读

我的代码如下:

if ($request->hasFile('featured_image')) {

    $realname = pathinfo($request->file('featured_image')->getClientOriginalName(), PATHINFO_FILENAME);
    $extension = $request->file('featured_image')->getClientOriginalExtension();
    $new_name = $realname."-".time().".".$extension;
    $request->file('featured_image')->storeAs('public/uploads',$new_name);
    $path = Storage::url('uploads/'.$new_name);
    $post->featured_image = $path;
    Image::make($path)->resize(320, 240)->insert($path);
}

我该如何修复这个问题?
1个回答

3
请使用图片的完整路径,而不是URL,例如:
Image::make(storage_path('uploads/'. $new_name'))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接