how can i redirect page while download box appears?
Now I got this code;
<?php
$file = "pain.png";
if (file_exists($file)) {
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');
开发者_Python百科 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;
}
?>
This code appears a download box. But I want to redirect this page to "Thank You" page while download box still here. How can i do this?
Thanks...
You can accomplish this using a Meta Refresh (http://en.wikipedia.org/wiki/Meta_refresh)
You would link from your homepage to your download page like this.
index.html
<html><head></head><body>
Download my awesome <a href="download.html">file</a>
</body></html>
download.html
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://example.com/download.php" />
</head>
<body>
Thanks for choosing Foobar! Your download will begin shortly.
If you're download does not begin,
click <a href="http://www.example.com/download.php">here</a>
</body>
</html>
Since the download is the HTTP response, you cannot do it from within the download response. You could redirect them and then say "thanks, your download will happen now" etc etc. This seems to be the standard solution most places.
To be clear, the thank you page would redirect to the download URL.
精彩评论