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:


$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;

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

function loadImage($id) {
$this->layout = 'none';

and the view load_image.ctp like this:

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

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:


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


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

Where is the error??