Elyass86's avatar

FatalThrowableError in UserController.php line 19: Class 'Image' not found

namespace App\Http\Controllers;

use Illuminate\Http\Request; use Auth; use Image; class UserController extends Controller { public function profil(){ return view('profile',array('user'=> Auth::user())); }

public function updateavatar(Request $request){
                // Handle the user upload of avatar
    if($request->hasFile('avatar')){
        $avatar = $request->file('avatar');
        $filename = time().'.'.$avatar->getClientOriginalExtension();
        Image::make($avatar)->save( public_path('/uploads/avatars/'.$filename ) );
         
        $user = Auth::user();
        $user->avatar = $filename;
        $user->save();
        return view('profile',array('user'=> Auth::user()));
    }

}

} i have installed intervention image on my project and set all configurations , i want to upload an image for my user profil but i got an error when i submit the form : FatalThrowableError in UserController.php line 19: Class 'Image' not found any suggestion please ??

0 likes
6 replies
Elyass86's avatar

oh thank you,it works but how can i resize a picture before saving without using intervention image??

pankajadhikary's avatar

Try it like this: In composer.json file "require": {

"intervention/image": "^2.4",
"doctrine/orm": "^2.5"

}, after that composer update , cache clear

Snapey's avatar

You just need to use Image; correctly. Try instead use Intervention\Image;

Please or to participate in this conversation.