0

I have the table users on mysql and added a column "image" which is a type binary (image png). When I show the image on a view, I use this code :

<p>Avatar: {{Auth::user()->image}}</p>

but it shows something like that: �PNG IHDR,,y}�u pHYs��tEXtSoftwareAdobe ImageReadyq�e<�nIDATx�� �Gy7����}K��]I�...

How can I solve this problem please ?

1 Answer 1

1

Try use something like this:

<img src="data:image/png{{-- change mime type if it's not png --}};base64,{{ base64_decode(Auth::user()->image) }}" />

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your help but it didn't work (the image is not shown) so I make some changes on the code, like this : <p>Avatar: <img alt="embedded image" src="data:image/png;base64,{{chunk_split(base64_encode(Auth::user()->image))}}"></p> And now it works :) (y)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.