【问题标题】:having problem while resizing image in laravel在 laravel 中调整图像大小时出现问题
【发布时间】:2021-11-01 17:29:22
【问题描述】:

在 laravel 中使用干预图像调整图像大小时出现错误

图书馆链接:http://image.intervention.io/

$featured_image = $request->file('featured_image');
$tmpFilePath = public_path('upload/properties/'); //Path to the Folder
$name = 'property_'.time().'.'.$featured_image->extension();
$featured_image->move($tmpFilePath, $name);

//Image resizing 
$image_original_path = $tmpFilePath.$name;
$image_resize = Image::make($image_original_path);              
$image_resize->resize(383,251);
$resize = public_path($tmpFilePath).'thumb_'.$name;            
$image_resize->save($resize);

并低于错误

Intervention\Image\Exception\NotWritableException
Can't write image data to path 
(/var/www/html/public/var/www/html/public/upload/properties/thumb_property_1630666129.jpeg)

【问题讨论】:

    标签: php laravel image resize intervention


    【解决方案1】:

    您在代码中使用了public_path() 两次,这会导致var/www/html/public/var/www/html/public/... 的路径无效。 改变

    $resize = public_path($tmpFilePath).'thumb_'.$name;
    

    $resize = $tmpFilePath.'thumb_'.$name;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 2020-08-16
      • 1970-01-01
      • 2019-02-25
      • 2017-12-09
      相关资源
      最近更新 更多