Alizey's avatar

Image Upload Problem Help Needed

I am getting this error while image uploading

Command (getClientOriginalName) is not available for driver (Gd).

public function doRegister()
    {
        $image = Image::make(Request::file('file'))->resize(100, 100);
        $destinationPath = 'uploads/';
        $image_name = time().'-'.$image->getClientOriginalName();
        $user = new User();
        $user->name = Request::input('name');
        $user->email = Request::input('email');
        $user->password = Hash::make(Request::input('password'));
        $user->contact = Request::input('contact');
        $path = Request::file('file')->move($destinationPath, $image_name);
        $user->user_img = $path;
            $user->save();
        Session::flash('message', 'User Successfully Registered!'); 
          return Redirect::to('/users');
    }

I Got This Error Command (getClientOriginalName) is not available for driver (Gd).

0 likes
4 replies
vipin93's avatar
public function doRegister()
      if (Input::hasFile('file'))
        {
           $file = Request::file('file') ;
         $imag = Image::make($file)->resize(100, 100);
        $destinationPath = 'uploads/';
        $image_name = time().'-'. $file->getClientOriginalName();
        }   
        $user = new User();
        $user->name = Request::input('name');
        $user->email = Request::input('email');
        $user->password = Hash::make(Request::input('password'));
        $user->contact = Request::input('contact');
        $path = Request::file('file')->move($destinationPath, $image_name);
        $user->user_img = $path;
            $user->save();
        Session::flash('message', 'User Successfully Registered!'); 
          return Redirect::to('/users');
    }
1 like
El_Matella's avatar

I had the same problem and it was that the image created by the function Image::make() was not compatible with the getClientOriginalName()

This is what I did:

    $chemin = Config::get('image.path');
        $image = Image::make($image)->encode('jpg');
        $extension = 'jpg';
        do {
            $nom = Str::random(10) . '.' . $extension;
        } while(file_exists($chemin . '/' . $nom));
        $img = Image::make($image);
        $img->fit(200);
        $img->save($chemin . '/' . $nom);
        //$image->move($chemin, $nom);
        return $nom;

I hope it can help you...

1 like

Please or to participate in this conversation.