i have a project with symfony 1.4, in an action a export a mysql table to a .csv file and next download it from the server, i’m using Wampserver for local developement, and everything is working ok, but, when i uploaded to the production server, now, if you try to export the data, the .csv file is automatically open in the browser without asking if you want to saved or open it, the code i use after creating the .csv is this
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
$this->getResponse()->setHttpHeader('Content-Type', 'text/csv');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="file.csv"');
$this->getResponse()->setHttpHeader('Pragma', 'no-cache');
$this->getResponse()->setHttpHeader('Expires', '0');
readfile(sfConfig::get('sf_upload_dir') . "/export/file.csv");
return sfView::NONE;
i repeat, in my local server this work ok, the browser give me the options of open or save, now, is this a problem of the code, a setting in the server or anything else??
the file is saved with utf-8 encode, is this the problem??
thanks
Thanks to the comments, i could get it work, what i did was change the content-type as @j0k suggested, and redirect to the file instead of using the
readfilefunctionnow it is working
thanks