Laravel 5.4图像调整大小问题

时间:2017-07-17 08:01:27

标签: laravel-5.4 intervention

我在laravel 5.4中调整图像大小时遇到​​问题

我使用以下代码调整图片大小:

    $sample_front_image = $request->file('sample_front_image');
    $input['sample_front_image'] = $sample_front_image->getClientOriginalName();
    $image_resize = Image::make($sample_front_image->getRealPath());              
    $image_resize->resize(120, 120);
    $image_resize->save(public_path($thumbnail_dir, $input['sample_front_image']));

但是我收到以下错误,如下所示: enter image description here

上面的代码似乎适用于以前的laravel版本,但是不适用于5.4版本。任何解决方案?

1 个答案:

答案 0 :(得分:1)

这是因为干预无法找到您传递的图像以进行调整大小。您正在为Image :: make()而不是实际路径提供临时图像路径。

首先,您必须使用store()将图像上传到某处,然后需要提供该图像到Image :: make()的完整路径。

希望这有帮助。

相关问题