Call to undefined method Intervention\Image\Facades\Image::make()

醉酒当歌 提交于 2020-08-27 22:14:42

问题


I upgrade from Laravel4.2 to Laravel5.3 with intervention/image : "^2.3",

 if (Input::hasFile('logo')) {

        $path = public_path()."/assets/admin/layout/img/";
        File::makeDirectory($path, $mode = 0777, true, true);

        $image      = Input::file('logo');
        $extension  = $image->getClientOriginalExtension();
        $filename   = "logo.$extension";
        $filename_big   = "logo-big.$extension";

        Image::make($image->getRealPath())->save($path.$filename);
        Image::make($image->getRealPath())->save($path.$filename_big);

        $data['logo']   =   $filename;

    }

The result I got error

Call to undefined method Intervention\Image\Facades\Image::make()

回答1:


I experienced the same issue in my Laravel 5.4 project. I stumble on this link

that help resolve the issue. This was the fix that was provided

In config/app change 'aliases' for Image from

  'Image' => Intervention\Image\Facades\Image::class,

To

'Image' => Intervention\Image\ImageManagerStatic::class,

Then in your controller header add

use Image;



回答2:


Make Sure that In config/app update Providers with

Intervention\Image\ImageServiceProvider::class

and update aliases with

'Image' => Intervention\Image\Facades\Image::class,


来源:https://stackoverflow.com/questions/40353307/call-to-undefined-method-intervention-image-facades-imagemake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!