PHP show image as BLOB mysqli

非 Y 不嫁゛ 提交于 2019-12-01 21:16:18

Try below

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

For better maintenance you can add data:image/png;base64 as your header then only echo base64_encode( $row['zdjecie'] ) this will work for single_image.php?id=$id

Using phpMyAdmin, I had to change the MIME display type to .jpeg on my MySQL image column = avatar_image. Once I made this simple change, it displays in the browser...i.e. the browser was getting the .jpeg data as a BLOB in raw form and did not know what to do with it...but it was a MySQL configuration = MIME type change on the MySQL column that fixed it.

  1. Don't store images in DB, it's performance suicide.
  2. Don't make your code vulnerable to SQLinjection.
  3. If you must store files in db, store content type. Maybe it's not a png? Or maybe you have a warning/notice printed out? It will break your image.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!