How to record and display images using Postgresql and Laravel 5.1

Asked

Viewed 683 times

0

I have the following code in my Controller to save the image in the database, not any error so I think it works right.

$data = Input::file('assinatura');
$escaped = bin2hex($data);
$tecnico->assinatura = $escaped;
$tecnico->save();

It looks like this on my chart:

inserir a descrição da imagem aqui

The problem is I don’t know how to display this image if I put:

<img src="{{ $tecnico->assinatura }}" />

Of that mistake:

Errorexception in helpers.php line 469:

htmlentities() expects Parameter 1 to be string, Resource Given

  • Raylan saving images as strings (since you use Hex and actually the most efficient would be Base64) or blobs in the database is a bad idea, always prefer to upload the image to the server and save in the database the path to where it is saved.

  • I imagine the upload is better @Brunorb, but since there are few images and small, I thought that recording straight would be easier. If you really can’t or show me that it’s really not worth anything I’ll try uploading to a directory on the server.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.