En el controlador:
App::uses('Folder', 'Utility'); .... public function view($id = null) { if (!$this->Autor->exists($id)) { throw new NotFoundException(__('Invalid autor')); } $options = array('conditions' => array('Autor.' . $this->Autor->primaryKey => $id)); $this->set('autor', $this->Autor->find('first', $options)); $dir = new Folder(WWW_ROOT . "autores/" . $id); $this->set('files', $dir->find(".*")); }
En la vista:
<h1>Archivos</h1> <ul> <?php foreach ($files as $file): ?> <li><?= $this->Html->link($file,"/autores/".$autor['Autor']['id']."/".$file) ?></li> <?php endforeach; ?> </ul>