My download file path is in application/app/upfiles
$this->view->setRenderLevel(View::LEVEL_NO_RENDER);
$request = new Phalcon\Http\Request();
if ($request->isPost()) {
if ($request->isAjax()) {
$fileid = $this->request->getPost('downloadpdf'); //get upload id from ajax post
$download = Upload::findFirst("upload_id = '$fileid'");
$filename = $download->upload_file;
$response = new \Phalcon\Http\Response();
$path = "app/upfiles/" . $filename;
$this->flash->error($path);
$filetype = filetype($path);
$filesize = filesize($path);
$response->setHeader("Cache-Control", 'must-revalidate, post-check=0, pre-check=0');
$response->setHeader("Content-Description", 'File Download');
$response->setHeader("Content-Type", 'octet-stream');
$response->setHeader("Content-Length", $filesize);
$response->setFileToSend($path, str_replace(" ","-",$filename), true);
$response->send();
die();
}
}
But not downloading, please any one resolve it