public function downloadFinally($id) { $res = Projects::downloadProject($id); $filename = "detyra/" . $res[0]->file; header("Content-disposition: attachment; filename=" . $filename); header("Content-type: application/" . $res[0]->ext); readfile($filename); Projects::addDownloads($id); }