Display blob as image
Posted: Tue Aug 16, 2011 12:49 pm
Hello All,
I read previous posts and followed the advice about mime types. Yet when I try to display a blob from a mysql database, php prints binary data on the page instead of rendering the data as in image.
This is a phonebook data base. And the entry is the users profile picture. The data structure for the image is a blob. Here is how I am printing the output:
I tried double quotes and single quotes in the mime type to avail. I still get binary data on the page intead of an image.
Thanks
KP
I read previous posts and followed the advice about mime types. Yet when I try to display a blob from a mysql database, php prints binary data on the page instead of rendering the data as in image.
This is a phonebook data base. And the entry is the users profile picture. The data structure for the image is a blob. Here is how I am printing the output:
Code: Select all
echo "<table cellspacing=\"0\" border=\"0px\" bordercolor=\"#aaaacc\" width=\"100%\" style=\"position: static; z-index: auto; \">";
echo "<tr> <td><b>First Name</b></td> <td><b>Last Name</b></td> <td><b>Extension</b></td><td></td></tr>";
//while($row = mysql_fetch_array($result))
while($row = mysql_fetch_assoc($result))
{
echo '<tr>';
echo '<td>'. $row['First'] .'</td>';
echo '<td>'. $row['Last'] .'</td>';
echo '<td> '. $row['Extn'] .'</td>';
$content = 'header(\'Content-type: image/png\')'.$row['Image'];
echo '<td>'. $content .'</td>';
echo '</tr>';
}
echo "</table>";Thanks
KP