songu Posted April 17, 2007 Share Posted April 17, 2007 Hello I am trying to create an image gallery that allows other users to upload images into. I want all the images to be displayed on the one page. I've figured out how to do this by using a table with a blob field. I've decided not to put the images in the directory as this method seems like it would be too complicated for my application. My problem: All the data is displaying properly, apart from the images. The images are being displayed as binary text. I have a suspicion that the header line is in the wrong place and that the "<img src='$imgdata'>" line is wrong, but I'm very new to PHP so I'm not sure. Any help would be very much appreciated. Thanks <html> <table width="100%"> <tr> <td>ID</td> <td>Item Image</td> </tr> <?php $query = "SELECT * FROM pix"; $result = mysql_query($query, $connection) or die(mysql_error()); header("Content-type: image/jpeg"); while ($row = mysql_fetch_array($result)) { $pid = $row['pid']; $imgdata = $row['imgdata']; ?> <tr> <td><?php echo $pid; ?></td> <td><?php echo "<img src='$imgdata'>"; ?></td> </tr> <?php } ?> </table> Link to comment https://forums.phpfreaks.com/topic/47412-displaying-blob-images/ Share on other sites More sharing options...
marcus Posted April 17, 2007 Share Posted April 17, 2007 You should be able to do: <img type="image/png" src="data:image/png;base64,$imgdata"> Link to comment https://forums.phpfreaks.com/topic/47412-displaying-blob-images/#findComment-231335 Share on other sites More sharing options...
songu Posted April 17, 2007 Author Share Posted April 17, 2007 Thanks for your reply mgallforever. Replacing <img src='$imgdata'> with <img type='image/png' src='data:image/png;base64,$imgdata'> still results in the binary data. Link to comment https://forums.phpfreaks.com/topic/47412-displaying-blob-images/#findComment-231629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.