, . JavaScript, window.location script.
, , .
, JavaScript.
:
index.php
<a href="thankyou.php">Click here to download.</a>
thankyou.php
<html>
<head>
<script type="text/javascript">
function startDownload() {
window.location = "/download.php";
}
</script>
</head>
<body onload="startDownload();">
<h1>Thank you!</h1>
<p>Your download will start in a moment. If it doesn't, use this <a href="download.php">direct link.</a></p>
</body>
download.php
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
Update
index.php script, GET. thankyou.php thankyou.php?download=12, - . script, :
index.php
<a href="thankyou.php?download=12">Click here to download.</a>
thankyou.php
<html>
<head>
<script type="text/javascript">
function startDownload() {
window.location = "/download.php?file=<?=$_GET['download']?>";
}
</script>
</head>
<body onload="startDownload();">
<h1>Thank you!</h1>
<p>Your download will start in a moment. If it doesn't, use this <a href="download.php?file=<?=$_GET['download']?>">direct link.</a></p>
</body>
script .