简体   繁体   中英

How to display an image that is stored in the database?

<?php
   $query = "SELECT * FROM table WHERE id = 2";
   $result = mysqli_query($con, $query);
   $result_set = mysqli_fetch_array($result);
   echo $result_set['img'];
?>

Why do shows strange characters, not image?

You need to add Content-Type header at the beginning, something like

<?
  header('Content-Type: image/png');
?>

for the PNG image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM