Hey,
This may be more of a Zend Framework issue but I’m putting it here in case any of you have seen it. I’ve been tasked with providing functionality that allows a download link from our Omeka powered site. It should stream the content so that the url is not made available.
I’ve got it all working bar the actual streaming (well, small fib, I have it working - just not in the way I’d prefer).
In a custom controller action I have:
$response = Zend_Controller_Front::getInstance()->getResponse();
$response->setHeader('Content-Type', 'application/zip', true);
$response->setHeader('Content-Disposition', 'attachment; filename="' . $zip->name . '"', true);
$response->setHeader('Content-Length', filesize($zip->path), true);
readfile($zip->path);
This should work and follows all the documentation I can find on the internet about doing this from within a Zend 1 controller.
But I get this error
PHP message: PHP Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
Getting my debugger up and running tells me it bombs out at line 588 of Zend_Controller_Response_Abstract, which as you can see is a simple echo statement.
For now I’ve fixed the issue by completely dumping out of the Zend response pipeline with
header('Content-Type: application/zip', true);
header('Content-Disposition: attachment; filename="' . $zip->name . '"', true);
header('Content-Length: ' . filesize($zip->path), true);
$obLevel = ob_get_level();
if ($obLevel > 0) {
do {
ob_get_clean();
$obLevel = ob_get_level();
} while ($obLevel > 0);
}
readfile($zip->path);
exit();
I’d rather not do this obviously as I imagine there a lot of fragile stuff I could be breaking, shutdown functions and the like.
Any ideas?
Thanks
Adam