Jump to content

Displaying blob images


songu

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.