Distribution des fichiers commandés

This commit is contained in:
Michael RICOIS 2014-08-04 13:59:20 +00:00
parent 2c1064b425
commit 99f808fa12
2 changed files with 30 additions and 1 deletions

View File

@ -206,6 +206,35 @@ class GestionController extends Zend_Controller_Action
$this->view->commandes = $commandesM->fetchAll($sql)->toArray();
}
public function downloadAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$c = Zend_Registry::get('config');
$path = $c->profil->path->data.'/'.$date.'/';
$file = $request->getParam('q');
$content_type = 'application/csv-tab-delimited-table';
//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.';
}
}
/**
* Load enrichissement batch to complete data

View File

@ -39,7 +39,7 @@ $Years = date('Y') - $YearBegin;
<td><?=$item['uniteInsee']?></td>
<td><?=$item['login']?></td>
<td><?=$item['critereReference']?></td>
<td><?=$item['fichier']?></td>
<td><a href="<?=$this->url(array('controller'=>'gestion','action'=>'download','q'=>$item['fichier']))?>"><?=$item['fichier']?></a></td>
</tr>
<?php endforeach; ?>
</table>