I have an image field that is of type BLOB in my MySQL database, I collect the data through PDO, but when viewing it it does not show me anything, I have searched the internet and everywhere I got the same thing with src="data:image/jpeg;base64
.
This is my code:
<?php
require_once './BaseDatos.php';
$id = $_GET['id'];
$bd = new BaseDatos('foro');
$imagen = $bd->SenetenciaSelect("usuarios", ["id"=>$id])[0]["image"];
echo '<img src="data:image/jpeg;base64,'.base64_encode($imagen) .' "/>';
The variable $imagen
returns this if I display it:
ÿØÿà\0JFIF\0\0\0\0\0\0ÿþ\0;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ÿÛ\0C\0 %# , #&\')* )-0-(0%()(ÿÛ\0C (((((((((((((((((((((((((((((((((( (((((((((((((ÿÀ\0@ \0\"\0ÿÄ\0\0\0\0\0\0\0\0\0\0\0\0 ÿÄ\0µ\ 0\0\0}\0!1AQa\"q2'¡#B±ÁRÑð$3br‚ %&\'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š'“”•–—˜™š¢£ ¤¥¦§¨©ª²³´µ¶ ¸¹ºÂÃÄÅÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ\0\0\0\0\0\0\0\0 ÿÄ\0µ\0\0w\0!1AQaq\"2B'¡± á etc.