I have a function which I use to enable downloading of files from a non-public directory. The downloading part works fine except that it does not prompt the user before and allowing the user to choose the location or just a simple open.
I use the following code:
$file = L_APP_BILAGOR."/".$_GET["f"];
$finfo = new finfo(FILEINFO_MIME);
$ct = $finfo->file($fileName);
if (file_exists($file)) {
header('Content-Type: '.$ct);
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
Can't seem to get it right. How do I force the browser to prompt the user before downloading the file?