Вот мой scanAction, который перечисляет файлы в каталоге:
Код: Выделить всё
public function listAction($client)
{
$dir_clients = $this->container->getParameter('dir_clients');
$dir_inter = ''.$dir_clients.'\\'.$client.'\\Interventions';
$interv = scandir($dir_inter);
$interv = array_slice($interv, 2);
$to_remove = array('Thumbs.db');
$interv_list = array_diff($interv, $to_remove);
return $this->render('MyBundle:Default:pilotage.html.twig', array(
// Here 'liste' = array of files in 'dir_interventions'
// 'dir_interventions' is a string of the directory
'liste' => $interv_list,
'dir_interventions' => $dir_inter,
));
}
Код: Выделить всё
{% for files in liste %}
[url={{ path(]{{ files }} [/url]
{% endfor %}
Код: Выделить всё
affiche_pilotage:
pattern: /pilotage/{repertoire}/file}
defaults: { _controller: MyBundle:Default:affichePilotage}
requirements:
repertoire: .+
file: .+
Код: Выделить всё
public function affichePilotageAction( $repertoire , $file )
{
$response = new Response();
$response->setContent(file_get_contents(''.$repertoire.'/'.$file.''));
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-disposition', 'filename='. $file);
return $response;
}
Подробнее здесь: https://stackoverflow.com/questions/424 ... l-symfony2
Мобильная версия