From 17c9b6905812af9f9ecbad794f0cf8d5fdc7896b Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 20 Feb 2012 11:46:39 +0000 Subject: [PATCH] Distribution du fichier csv --- application/controllers/IndexController.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 08787bf9..788f492f 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -54,6 +54,23 @@ class IndexController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $file = $request->getParam('file', ''); - echo file_get_contents('/sites/dataenrichissement/export/'.$file); + $content_type = 'application/csv-tab-delimited-table'; + $path = '/sites/dataenrichissement/export/'; + //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.'; + } + + } } \ No newline at end of file