Table User
image(blob type) ------------------------------ 0xFFD8FFE0
myController
function displayImage($id)
{
$this->autoRender = false;
$peoples=TableRegistry::get('peoples');
$peoples=$peoples->getRecord([ 'image'])->first();
header('Content-Type: image/jpeg');
echo $peoples['image'];
}
Model
function getRecord($fields)
{
return $this->find('all')->select($fields);
}
But when I set this:
<img id="imgPreview" src="displayImage/30">
the image does not show anything. When I use myController/displayImage/30
this shows Resource id #170
to me!
Why is this? How can I display the image?