显示其他内容的BLOB图像

Firstly this is for a simple university project, so time is more important than performance of database etc.

I have a database with images stored in blob files. Now some form outputs data from this database, but i want it to also output the image, along with the text.

I realise there is a bit of code to change headers to image, but then the text wont display, so is there a way to display the image and the text on the same page?

thanks a lot,

It is possible to embed images inside HTML, but you usually do it only if you have a really good reason to. Assuming you do, you write the following code, provided that $BLOB is the binary raw data of the image:

<img src="data:image/jpeg;base64,<?php echo base64_encode($BLOB); ?>"/>

Why not use image tags like normal wherever you need the images to be, and in the src attribute, specify a PHP script along with a get argument (for instance, <img src='image.php?name=something.jpg'>). This script then authenticates the request, accesses the database, sends the appropriate headers, followed by the actual BLOB data.