页面在下载过程中不会重定向到任何其他页面


Page not redirect to any other page during download

我有一个网页,其中有下载文件的选项。下载是可以的,但在下载过程中,页面不会重定向到另一个,直到下载完成。

我用来下载文件的代码如下:

header("Content-Type: application/force-download");
header("Content-type: application/octet-stream");
header("Content-Disposition: inline; filename=NRI legal services_".$row['document_path']);
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);

请帮忙把它整理一下。提前谢谢。

也许你需要制作一个包装页面,比如01net,它有一个下载链接的链接(在你的例子中是上面的php文件),然后使用javascript重定向到感谢页面。你不能按照你想要的方式去做。