i am trying to download excel files that i have uploaded to the server using web form
i am using ubuntu 10.04, symfony 1.4 and doctrine 1.2
when i click the link, it downloads, but a corrupted file. the code is as follows
public function executeDownload(sfWebRequest $request)
{
$excel_file = Doctrine::getTable('Project')->find($request->getParameter('id'));
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
$excelpath = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'project'.DIRECTORY_SEPARATOR.$excel_file['file'];
// check if the file exists
$this->forward404Unless(file_exists($excelpath));
$response = $this->getContext()->getResponse();
$response->setHttpHeader('Pragma', '');
$response->setHttpHeader('Cache-Control', '');
$response->setHttpHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->setHttpHeader('Content-Disposition', 'attachment; filename="invoice.xlsx"');
$response->setContent($excel_file);
return sfView::NONE;
}
i have checked the original uploaded file and it seems to be ok. I have also checked
for available mimetypes at /etc/mime.types and support for 2007 excel format is there
But i can’t figure out why the download has a problem.