html - PHP: How to display TEXT data image directly in browser?


My website stores pictures in a TEXT mysql field and displays them like:

extract of database:


and they are displayed that way

<img id="image" class="page_speed_1025506044" src="<?=$row["data"];?>">

I would like some images to be accessible directly like in browser: (id=field 1 of database)

(with no html, just pure JPEG image)

so it returns a pure JPEG image (I guess some headers to be stup as JPEG).

Any clue for that ?

enter image description here




I am pretty sure you can get around that with MIME Headers ( that will be sent to the browser so that it knows how to interpret the data that it is being fed and display it correctly as an image (or whatever type of data you are sending to the user).

header('Content-Disposition: inline');
header('Content-type: image/png');
echo "yourImageData";



Simply removedata:image/png;base64, from the beginning of the data,base64_decode the rest of it – and output that decoded data after aheader('Content-Type: image/png') … done.

People are also looking for solutions to the problem: php - Picasa video wordpress


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.