【发布时间】:2011-12-05 02:15:10
【问题描述】:
基本上,我们有一个 PHP 文件,它使用 PHP 标头输出文件类型。
我们希望它像这样工作:
用户单击链接,页面打开,出现下载提示,然后提示下载的页面(主 php 页面)重定向到另一个页面...
我该怎么做呢?我希望它仅在下载提示发送给用户后重定向。
所以.. 有点感谢页面。
可以这样做吗:
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: public', false);
header('Content-Description: File Transfer');
header('Content-Type: '.$type);
header('Accept-Ranges: bytes');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file));
/* sleep for say 3 seconds.. */
header('Location: thankyou.php');
exit();
此代码纯粹是作为示例编写的,但是我们如何创建这样的代码呢?
于是弹出下载提示,等待 3 秒,然后将源页面指向感谢页面。
【问题讨论】:
-
为什么不去无数这样的下载页面之一看看它是如何工作的?
-
什么是数以亿计的下载页面?
-
相同功能的页面。就像 download.com 或无数类似网站上的一个。
标签: php