Hi everyone!

I'm looking for a way to display a blob image into a view.

With a simple website (not CakePHP) this was very simple, just retrieve the blob field from db and then print it after the specific of Content-type, like this:

[PHP]
[...]


$query = mysql_query("SELECT data FROM images WHERE id=2 LIMIT 1");
$row = mysql_fetch_array($query);
$content = $row['data'];

header('Content-type: image/jpeg');
print $content;
[/PHP]

I don't know why with CakePHP I'm going crazy!! I've write the controller like this:

[PHP]
function loadImage($id) {
$this->layout = 'none';
$this->set('file',$this->Image->findById($id));
}
[/PHP]

and the view load_image.ctp like this:

[PHP]
Configure::write('debug', 0);
header("Content-type: image/jpeg");
echo $file['Image']['data'];
[/PHP]

The result is a blank page with nothing to display. If I comment the Content-type the view display only a lot of chars... I've also try to call this from img tag in an another view, for example:

[PHP]

echo $html->tag('img', null, array( 'src' => Router::url(array('controller' => 'Images', 'action' => 'loadImage', 2) ) ) );

[/PHP]

But nothing..... wink.gif wink.gif

Where is the error??