Home > Net >  Image not displaying in php when fecthed from database in longblob
Image not displaying in php when fecthed from database in longblob

Time:01-18

I am facing an issue with the php code as it is not displaying the image - I don't know what is wrong with the code

php/HTML code

<img src="data:image/jpg;base64,'.base64_encode($row['MovieImage']).'" />

when I inspect I get this value:

<img src=data:image/jpg;base64,IP/Y/ AAEEPGSUYAAQEAAAEAAQAA/
9sAQwADAgICAgIDAgICAwMDAwQGBAQEBAQIBgYFBgldCgoJCAkJCgWPDAOLDgsJCQORDQ4PEBAREA MEHMSEBMPEBAQ/
9sAQwEDAwMEAWQIBAQIEASICKAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ/
BAAEQgCIAGOAWERAAIRAQMRAF/EAB4AAAAHAQEBAQAAAAAAAAAAAAADBAUGBwgCAQKK/
8QAUHAAAQMDAwIDBQYDBQUFBQUIAQIDBAAFEQYSIQEDFRCBQIMmEVIOJSCYEzYpEWQ3KhsQkkUSHRITSCKAXY6Ky8VRzq7TC4RgKD U4dZOj/8QAHAEAAQUBAQEAAAAAAAAAAAAAAAECAWQFBgcl/
8QAQBEAAgEDAWIDBQgBAgMIAwEAAAECAWQRBRIHMIATOWEGIIGHORQYcYGRseHxwRUJB0JJDNSgpLCOV/Wsuki/ 90ADAMBAAIRAxEAPwD6A 4uFYAGK6d1Ucd4LHeHZN71S5yMVVqXHwJadvkck2FqGVrZSEJWMqP1qqq 7qXIS29ApEhaeA5kJ/

CodePudding user response:

Be careful where you set quotes.

echo '<img src="data:image/jpg;base64,' . base64_encode($row["MovieImage"]) . '" />';

CodePudding user response:

You do not need to encode once again if $row['MovieImage'] is already base64

  • Related