Hi all,
i'm trying to output an image in a controller action. However i can't get it to work. If i run the same code in a regular php file it runs fine, but when i run it in a controller i can't get it to work.
/**
* @param $systemName
*/
public function overviewAction($systemName)
{
$tournament = Tournament::findFirstBySystemName($systemName);
if ($tournament) {
if ($image = (string)$tournament->challonge->getOverviewImage()) {
$this->response->resetHeaders();
$this->response->setHeader('Content-Type', 'image/png');
$tmpFile = $this->config->application->cacheDir . $systemName . '.png';
file_put_contents($tmpFile, file_get_contents($image));
$original = new \Phalcon\Image\Adapter\GD($tmpFile);
$original->crop($original->getWidth(), $original->getHeight() - 150);
$original->save();
readfile($tmpFile);
}
}
$this->view->setRenderLevel(View::LEVEL_NO_RENDER);
}
I have tried it with a die at the end, setting headers in the normal fashion, different ways of outputting the file, removing the renderLevel thing etc.
Am i missing something?
Thanks!