I have an image field that is a BLOB type in my MySQL database, I collect the data by PDO, but at the time of viewing it, it does not show me anything, I searched the Internet and everywhere I put 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 visualize it:
yoya \ 0JFIF \ 0 \ 0 \ 0 \ 0 \ 0 \ 0ÿþ \ 0; CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 YU \ 0C \ 0% #, # & \ ') *) - 0- (0% () (ÿÛ \ 0C (((((((((((((((((((((((((( (((((((((((((((ÿÀ \ 0 @ \ 0 \ "\ 0ÿÄ \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 ! Ya \ 0μ \ 0 \ 0 \ 0} \ 0 1AQa \ "# B ± q2'¡ Arnd $ 3BR,% & \ '() * 456789: CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ" ... ‰ Š ‡ †' "" • - ~ ™ š ¢ £ ¤ ¥ |§ © ª²³'μ¶ ØÙÚáâãäåæçèéêñòóôõö × ÷ · ¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ øùúÿÄ \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 Ya \ 0μ \ 0 \ 0w \ 0! 1AQaq \ "2B'¡ ± Á etc.