gestion des headers

This commit is contained in:
Damien LASSERRE 2012-04-12 09:46:16 +00:00
parent 3e48103956
commit 6a22104b36

View File

@ -218,20 +218,23 @@ class EnrichissementController extends Zend_Controller_Action
public function downloadAction()
{
$id = $this->getRequest()->getParam('id');
if(!empty($id)) {
$table = new Table_EnrichissementIdentifiants();
$sql = $table->select()
->where('id = ?', $id);
$result = $table->fetchRow($sql);
if(!empty($result)) {
$result->toArray();
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/configuration.ini');
if(file_exists($result['fichier']))
echo file_get_contents($result['fichier']);
else
echo 'Le fichier n\'éxiste plus...';
}
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/configuration.ini');
$path = $config->path->data;
//Envoi du fichier sur la sortie standard
if ( file_exists($path.'/'.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
exit;
}