I am trying to deliver a CSV file through an action. The mime type in the response is still displayed as text / html. Can anyone help? Thanks
//$this->setLayout(false); //$this->getUser()->shutdown(); //sfConfig::set('sf_web_debug', false); $response = $this->getContext()->getResponse(); $response = $this->getResponse(); $response->clearHttpHeaders(); $response->setHttpheader('Pragma: public', true); $response->addCacheControlHttpHeader('Cache-Control', 'must-revalidate'); $response->setContentType('application/octet-stream', true); $response->setHttpHeader('Content-Description', 'File Transfer'); $response->setHttpHeader('Content-Transfer-Encoding', 'binary', true); $response->setHttpHeader('Content-Length', filesize($file_path)); $response->setHttpHeader('Content-Disposition', 'attachment; filename="' . $file_name . '"'); $this->getResponse()->sendHttpHeaders(); //$response->setContent(file_get_contents($file_path)); //readfile($file_path); $this->renderText(file_get_contents($file_path)); //return sfView::NONE; return sfView::HEADER_ONLY;
Believe me, before I get here, I have all the search results purple. Since you can see all the permutations and combinations above, I still couldn't get this to work!
source share