Hi All! My first post here. More to come... ;)
I have a question regarding the MVC implementation and sending headers.
Say I write an action that should just output an image. An action that can be
used like this:
<img src="/module/controller/output/imgId/1529" alt="" />
Say I have a library class calld My_Image that does all the GD magic to output
an image.
Then I do this in my action controller:
function indexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$img = new My_Image('/path/to/1529.jpg');
// ...
$img->outputToBrowser();
}
In this case the My_Image::outputToBrowser method sends all the header()s that
we need
to send and then stops the script execution with an exit;
Is this the correct way of doing this? Or should I rather send the headers in
the controller like...
$this->getResponse()->setHeader('Content-Type', 'image/jpeg');
// ...
$img->outputToBrowser();
.. and then let the dispatch loop continue?
Just need some advice on this, because I'm afraid that I miss out on something
if i send the
headers and exit on my own. Whats the best practice in this case?
Thanks in advance!
/Filip - from sweden
_________________________________________________________________
Mörkt och kallt? Kanske Barcelona?
http://search.live.com/results.aspx?q=Barcelona+reseguide&form=QBRE