Hi,
I'm using cake1.2 and I've got a blob stored in my database. I'm
trying to display it using
$html->image(array('controller'=>'image_files','action'=>'show',
10));
I'm trying to get the requestHandler to set the correct header-type
for the request but every time I load the page I get the raw image
output in the view and the response header type shows as text/html in
firebug for the get '/images_files/show/10' request.
I've tried moving the output from the show action into the layout and
but it still doesn't seem to work.
function show($id)
{
Configure::write('debug', 0);
$this->layout = 'pic';
$this->autoRender = false;
if ($image = $this->BlobFile->find('first', array('conditions'
=> array('images_id' => $id))))
{
$this->RequestHandler->respondAs(strtolower($image['BlobFile']
['file_extension']));
$this->set('blob', $image);
}
}
my pic layout is simply print $blob['ImageFile']['file_content'];
function beforeFilter()
{
parent::beforeFilter();
$this->RequestHandler->accepts(array('png','jpg','jpeg'));
$this->RequestHandler->setContent('png', 'image/png');
$this->RequestHandler->setContent('jpg', 'image/jpeg');
$this->RequestHandler->setContent('jpeg', 'image/jpeg');
}
I've also tried calling requestHandler->respondAS(null); and even
tried creating my own component and extending the requestHandler.
I've been trying to tackle this bugger for the last 2 days in various
ways and I've even copied verbatim some of the samples from google but
they all use header('Content-type: image/jpeg'); in the layout and
that didn't seem to work for me either.
Any tips or insight on this would be great.
Thanks.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php