在 laravel 中调整图像大小时出现问题
having problem while resizing image in laravel
我在 laravel 中使用 Intervention Image
调整图像大小时出错
图书馆的 Link: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)
您在代码中使用了 public_path()
两次 ,这导致了无效路径 var/www/html/public/var/www/html/public/...
。
变化
$resize = public_path($tmpFilePath).'thumb_'.$name;
至
$resize = $tmpFilePath.'thumb_'.$name;
我在 laravel 中使用 Intervention Image
调整图像大小时出错 图书馆的Link: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)
您在代码中使用了 public_path()
两次 ,这导致了无效路径 var/www/html/public/var/www/html/public/...
。
变化
$resize = public_path($tmpFilePath).'thumb_'.$name;
至
$resize = $tmpFilePath.'thumb_'.$name;