Hello, I'm really lost trying to get a file download. I have my files for download in this file estructure:
/app /controllers /models /views /var /user_documents <- here /public ...
My files in /userdocuments have numbers for names: 1, 2, 3.. And the real name is store in the database. The thing is I don't know how to get to a file like /var/userdocuments/1 so I'm able to read it. I don't know if I need to set some routes or permissions there.
When I read it I want to use this code I saw in the forum for downloading it, but I don't know if it's the right way either:
$this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_NO_RENDER); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Description: File Transfer'); header('Content-type: ' . $filetype); header('Content-length: ' . $filesize); header('Content-Disposition: attachment; filename="'.$filename.'"'); readfile($file); die();