在此项目中,我尝试将图像保存在默认路径中,然后将自定义图像保存在其他路径中,但出现此错误
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
我的Laravel版本是6,并且在app.php中也设置了类
Intervention\Image\Exception\NotReadableException
Image source not readable
在我的控制器中,我有以下代码
'aliases' => [
// 'Image' => Folklore\Image\Facades\Image::class,
'Image' => Intervention\Image\Facades\Image::class,
'ImageResize' => Intervention\Image\Facades\Image::class,
],
'providers' => [
// 'Image' => Folklore\Image\Facades\Image::class,
'Image' => Intervention\Image\Facades\Image::class,
'ImageResize' => Intervention\Image\Facades\Image::class,
],
答案 0 :(得分:0)
$image = $request->file('image');
$slug = str_slug($request->title);
if (isset($image))
{
$currentDate = Carbon::now()->toDateString();
$imagename = $slug.'-'.$currentDate.'-'. uniqid() .'.'. $image->getClientOriginalExtension();
$image_resize = Image::make($image->getRealPath());
$image_resize->resize(1600,1066);
if (!file_exists('storage/uploads/post'))
{
mkdir('storage/uploads/post',0777,true);
}
$image_resize->save('storage/uploads/post/'.$imagename);
}else{
$imagename = "default.png";
}
'aliases' => [
'Image' => Intervention\Image\Facades\Image::class
],
'providers' => [
Intervention\Image\ImageServiceProvider::class
],