gestion des download par id

This commit is contained in:
Damien LASSERRE 2012-04-13 08:13:22 +00:00
parent 2931f21cc4
commit d2cd06d96b

View File

@ -129,7 +129,6 @@ class EnrichissementController extends Zend_Controller_Action
'error' => '',
'dateAdded' => date('YmdHms'),
);
//print_r($data);exit;
$identifiantsM = new Table_EnrichissementIdentifiants();
$idIdentifiant = $identifiantsM->insert($data);
exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$idIdentifiant);
@ -219,21 +218,30 @@ class EnrichissementController extends Zend_Controller_Action
public function downloadAction()
{
$file = $this->getRequest()->getParam('fichier');
$id = $this->getRequest()->getParam('id');
$table = new Table_EnrichissementIdentifiants();
$sql = $table->select()
->where('id = ?', $id);
$result = $table->fetchRow($sql);
if(!empty($result)) {
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/configuration.ini');
$result = $result->toArray();
$date = explode(' ', $result['dateAdded']);
$path = $config->path->data.'/'.substr($date[0], 0, 7).'/';
$file = $result['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) ) {
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('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);
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}