I have a webservice I'm connecting to. I'm getting valid responses back for my queries, and one of them is an IMAGE type. I'm not in direct control of the DB, and they don't really offer support - so I can't ask them about the specifics.
I need to offer links to display or download this image. This should be easy enough, but I've been banging my head against this for quite a while now.
I have the IMAGE data. I have put this in a var called $evidence. If I do the following, I get a corrupt/unreadable image across all browsers I've used (broken image link symbol or similar text):
header("Content-type: image/jpeg");
echo $evidence;
So, while debugging this I tried to display the image inline using some copy/pasta'd code:
echo '<img src="data:image/jpeg;base64,'.$evidence.'" />';
This works as expected... the image is shown correctly.
However - I need to be able to do this the correct way via a header, as I need to do other things, such as be able to force downloads.
Every time I've ever had to do anything like this, the basic "header, echo" approach has always worked. By the looks of almost every tutorial out there: this should work. It seems to be so simple, most tutorials don't even look at display problems (only data fetching problems).