mercredi 1 novembre 2017

Laravel image encrypt and store into db

I need user image content to be encrypted and store into database and then decrypt before display .My code in controller to encrypt,

public function savePicture(Request $request)
{
     $file = Input::file('pic');
     $img = Image::make($file);
     Response::make($img->encode('jpeg'));

     $picture = new Picture;
     $picture->name = $request->get('name');
     $picture->pic = $img;
      $picture->pic=Crypt::encrypt(file_get_contents($file));
      //dd($picture);
     $picture->save();

}

When I run this code I got the error PDOStatement::execute(): MySQL server has gone away (SQL: insert into pictures (name, pic, updated_at, created_at)... How do I solve solve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire