I am trying to download a file thats already uploaded in cakephp app
folder. I am using the function below in my controller but it just opens a
blank page without even downloading the file
public function download($id = null) {
$this->viewClass = 'Media';
// Download app/outside_webroot_dir/example.pdf
$adminProcedure = $this->AdminProcedure->findById($id);
$filename = $adminProcedure['AdminProcedure']['filename'];
$this->request->params = array(
'id' => $adminProcedure['AdminProcedure']['id'],
'name' => substr($filename, 0, strrpos($filename, '.')),
'extension' => substr(strrchr($filename, '.'), 1),
'ext'=>'pdf',
'download' => true,
'path' => APP.'admin_procedures'.DS,
);
$this->set($params);
}
In my view i have used this bit of code to link to the file im trying to
download.
?php echo $this->Html->link(__('Download', true), array('action' =>
'download', $adminProcedure['AdminProcedure']['id'])); ?>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.