Afficher une image BLOB

Résolu/Fermé
Sinistrus Messages postés 1017 Date d'inscription mercredi 12 décembre 2007 Statut Membre Dernière intervention 6 juin 2023 - 11 mai 2017 à 00:23
Sinistrus Messages postés 1017 Date d'inscription mercredi 12 décembre 2007 Statut Membre Dernière intervention 6 juin 2023 - 11 mai 2017 à 10:46
Bonjour à tous !

Ce bout de code me renvois une image encodée, ou plutôt un texte encodé.
Pouvez-vous m'aider svp ?
<?php
if (isset($_POST["action"]) && $_POST["action"] == "send"){
	
$Fr_Type			= $_FILES['Fr_Photo']['type'];
$Fr_Photo			= file_get_contents($_FILES['Fr_Photo']['tmp_name']);

$req_fr = $pdo->prepare ("INSERT INTO tb_maman (Type, Photo) VALUES (:Fr_Type, :Fr_Photo)");
$req_fr ->execute(array(
"Fr_Type"	 		=> $Fr_Type,
"Fr_Photo"	 		=> $Fr_Photo));
}
?>

<?php $MyPDO = $pdo->query("SELECT * FROM tb_maman ORDER BY RAND()"); while($data = $MyPDO->fetch(PDO::FETCH_ASSOC)){ ?>

<img src="<?php echo $data["Photo"]; ?>" width="100%" alt="" >

<?php } ?>




2 réponses

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
11 mai 2017 à 00:57
Bonjour,

l'image est encodée en 64..
pour l'afficher tu dois utilser
echo '<img src="data:image/jpeg;base64,' .echo $data["Photo"] . '" />';

3