I have some php code that looks like:
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
echo 'test';
After this block the view is loaded to render the html for the page to be displayed.
The problem is that all the html on the page afterward is also part of the file download. How can I resume normal browser output so that only the echoed text is sent to the file download?