0

I am trying to display an image from the database, however, the image does not appear, but instead, an image icon appears, see image

this is the image icon with 2 warnings

if(isset($_POST['submit2']))
{
    $usertable = "table1";
        $db  = new mysqli('localhost', 'root', '', 'testdb') or die("unable to dbect");

        $sql = mysqli_query($db,"SELECT image1 FROM table1 WHERE id = '1'");
        $sth = $db->query($sql);
        $result = mysqli_fetch_array($sth);
        echo '<img src="data:image/jpeg;base64,'.base64_decode( $result['image'] ).'"/>';
}

if anyone could fix the code, thank you very much

sami
  • 1
  • 1

1 Answers1

0

actually it suppose to be Base 64

for that you have given echo '<img src="data:image/jpeg;base64 so you should not encrypt or decrypt it .

more How to display image from database using php

Try

echo '<img src="data:image/jpeg;base64,'.$result['image'] .'"/>';
Swarna Sekhar Dhar
  • 550
  • 1
  • 8
  • 25