I am using mssql server and CI in which it auto backups the db file into certain folder now I need to let the user download the file from the server to her local machine.
$filename = basename($_GET['file']);
// Specify file path.
$path = 'backups/hello.txt';
$download_file = $path.$filename;
if(!empty($filename)){
// Check file is exists on given path.
if(file_exists($download_file))
{
header('Content-Disposition: attachment; filename=' . $filename);
readfile($download_file);
exit;
}
else
{
echo 'File does not exists on given path';
}
}
}
I have tried this one but it says file is unknown.