Reputation: 1
I am trying to retrieve an image from a database (blob) field and render it on a web page. Outside of Zend, in a test application this works fine. However, within the Zend framework the rendering fails. Instead, the URL will show on an otherwise blank page. If I include a Zend_Debug statement, it shows the full binary stream retrieved from the db (MySQL). Here is some of the code I'm using:
<?php
$result = $q->fetchArray(); //fetch result from the database through Doctrine
header("Content-Type: {$result[$seq]["mimeType"]}"); //get MIME type from db, set header
$pict = $result[$seq]["picture"]; //get image from db blob field
// echo Zend_Debug::dump($pict, '$pict');
?>
If anybody can shed some light on this problem I would be very grateful. Thanks, Jan
Upvotes: 0
Views: 439
Reputation: 1943
There is a built-in helper that does exactly that. Dont use the php header() function, use
$this->headMeta()->appendHttpEquiv('Content-Type', $this->result[$seq]["mimeType"]);
Kind of like that. You can do it in the view or in the controller or whatever you are using. http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headmeta
Upvotes: 0
Reputation: 11217
This is not the "zend way". You should use your response object methods to set headers and then use sendHeaders() and sendBody() to fire the response. Disabling layout should not be needed.
Upvotes: 1