Hello,
I have the need to display images stored as BLOB's in a MySQL table.
phpMyAdmin shows them nicely with its inline feature.
Some basic PHP code (test.php) displays the image nicely as below
$sql = "SELECT logo FROM providers WHERE id=6";
$result = mysql_query("$sql") or die("Invalid query: " .
mysql_error());
header("Content-type: image/png");
echo mysql_result($result, 0);
This results is a nice image when I browse to test.php
I can also refer to it from another page using <IMG SRC="test.php">
But I can't get Cake to show the images. All I get is the raw data as
text.
So far this is what I've done.
In my controller I have a function
function logo($id)
{
$this->set('data', $this->Provider->findById($id));
$this->render('logo','ajax');
}
The BLOB is found thus in $data['Provider']['logo']
In my logo.thtml view I have
<?php
header("Content-type: image/png");
echo ($data['Provider']['logo']);
?>
The result if I browse to /provider/logo/6 is a page of text (the raw
image data)
PNG IHDR etc...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---