0
I have a bmp image saved in the database, but this file is already in the database and was not included in the framework, I would just like to know how to show this image in the view.
Note: I have tried the method:
No Controller:
I take the desired records and access the field containing the image.
$query->resultado;
Na View:
<img src="{{asset('data:image/bmp;base64,'.base64_encode($query->resultado).'')}}">
I tried other ways indicated on the Internet and I was unsuccessful, if anyone can give me any light it would help me a lot already.
What framework you are using?
– vinibrsl
I’m using Laravel, marked on the tag below !
– Lincoln Binda
what is the result you are getting in the $query->result variable? put this result to get better understanding!
– PV Telles
As the field contains an image, the return is. ---->D6BC4F30B513740F2EABF1A45B3CB140F5840400DE63AA05
– Lincoln Binda
@Lincolnbinda, the Base64 of this return ñ looks like an image: Nzg5qzczrjjgrem2qzywmda2njy0mefdmdfdndeyntbdqza4mjyxote4meuwme1oezgmdqxmzay Remx4ocm4ocln0yzmemwmtq4mta4rti2mjyzmzxigizigiswndremtzbrtbcneuymjhcrtm3muka jOKAizBDQTZBQjQ4MzUwNzREMkYzMU24oCM4oCLRTBGMjE0MkVCNzExRUYxRTVDQzHigIzigIs0 Qjvenzm0odhequmtayja0nokajokaizmxmjvfnjkwmteynkzgntewmtlb4ocm4oclmjaxoue2
Odq0odgznza34ocm4oclqkzdotu4rjmyqzlfmda0n0qzoeligizigis2nji5rdzcqzrgmzbcntez Nzqwrukajokaizjfqujgmue0nuizq0ixndbgntg04ocm4mdqwmerfnjnbqta1iokakwo=
– nunks
@To see if it works, I suggest taking the return of the base64_encode($query->result) and replacing it in a tag
<img>
static: <img src="data:image/png;Base64,[image coded in Base64]" />– nunks
@nunks.lol Thank you very much for being willing to help, but that’s exactly what I did, when I put the return of the query result in Base64 in a <img> tag it just doesn’t appear, as if the image didn’t exist, but it exists because I put it in real time.
– Lincoln Binda
@Lincolnbinda understand, is what happened here with me also using the Base64 of the return you posted in a comment above. What I mean is that this doesn’t look like an image, but rather a BMP, because it’s very little information. I got that image of a black circle, reduced to 10x10 px and yet the returned Base64 is larger than it fits in a stackoverflow comment. You have a way to ensure that the image’s Encode is correct when inserting into the bank?
– nunks
@nunks.lol I understand, I have no way to guarantee on the Meeting when inserting in the bank, even because the image is inserted through a game, it works like this, the character creates a Guild, this Guild has the option of having badge, when changes the emblem of Guild, automatically the Guild record of the database table wins the badge in one of its fields, which in this case is called 'emblem_data'.
– Lincoln Binda
try saving a disk badge manually and run
base64 [nome_do_arquivo]
(this works on linux) to compare the result with the same emblem consulted in the database, maybe give a light... what is your code to insert the image in the database?– nunks
Check the size of the field in your table, the result may be being saved missing information because of the space reserved for this field!
– PV Telles