webservice/application/controllers/FichierController.php

36 lines
1.1 KiB
PHP

<?php
class FichierController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function bodaccAction()
{
$configuration = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
$directory = realpath($configuration->data).'/bodacc';
$q = $this->getRequest()->getParam('q');
$file = base64_decode($q);
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
}
}