Page 1 of 1

Upload and display images stored in innoDB table (BLOB Type)

Posted: Fri Oct 13, 2006 6:14 pm
by amir
Hi,

I'm Trying to upload and display images stored in an innoDB table (BLOB Type)

I can do it with on a MYISAM table, but I tried to do it with on an INNODB table, and it doesn't work!

Here's the PHP code I use to display the image :

<code>
... database connection and recordset ...

header("Pragma: no-cache");
header("Content-type: " . $row_rsBlob['logoType']); // image/gif
echo (($row_rsBlob['logo'])); // the binary data
</code>

I get the following message (Firefox) : The image "http://www.mydomain.com/displayImage.php" could not be displayed because it contains errors (translated from french)

Of course, I'v tried with several images and (I repeat), I'v already done it on a MYISAM table (the only difference I noticed) and it was OK

Here's the PHP code and SQL query I use to upload the file in the database:

<code>
...
$id = $_GET['id'];
$myImgData = addslashes(fread(fopen($formFile, "rb"), filesize($formFile)));

$updateSQL = "UPDATE myTable SET myTable.logo='$myImgData', myTable.logoType='$formFile_type' WHERE id=".$id;
...
</code>

Thanks for your help, I'm loosing time and the deadline is coming soon...

Posted: Fri Oct 13, 2006 6:23 pm
by Ollie Saunders
When you get
FireFox wrote:The image "http://www.mydomain.com/displayImage.php" could not be displayed because it contains errors
View the source and see if there aren't any error or extra characters at the start.