public function downloadMe(){
$file = $_GET['sampleFile'];
$filename = 'uploads/'.basename($file); //path to the file on disk
if (file_exists($filename)) {
//set appropriate headers
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
//read the file from disk and output the content.
readfile($filename);
exit;
}
}
No comments:
Post a Comment