头文件下载后重定向 [英] Header redirect after download

查看:144
本文介绍了头文件下载后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,逐步学习。那么我有一个下载页面,我想在下载完成后被重定向。

I am new to PHP and learning it step by step. Well I've a download page that I want to be redirected after the download has been completed.

header('Content-type: application/octet-stream');                 
header('Content-Disposition: attachment; filename="dlink.pdf"');                  
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");                  readfile('dlink.pdf');   
header("refresh: 2; auto_works.html");
exit;

这是我的PHP代码中包含的下载代码。我如何实现我的指令?请帮忙。你还可以提到我应该在哪里编写代码行

This is my download code enclosed within the PHP tag. How can I achieve my directive ? Please help. Could you also mention to me where am I supposed to write the line of code

谢谢

推荐答案

下载完成后,无法重定向。网络服务器(将执行重定向)不知道什么时候下载完成。有一些方法,但它们很困难,不值得。

You can't redirect after the download is complete. The webserver (which would do the redirect) doesn't know when the download is complete. There are ofcourse ways, but they're difficult and not worth it.

下载开始后,您应该重定向。

You 'should' redirect after the download started.

这篇关于头文件下载后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆