php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com6年前PHP代码库
跳转核心代码实现。
复制代码 代码如下:

if (isset($link))
                {
                    Header("HTTP/1.1 303 See Other");
                    Header("Location: $link");
                    exit;
                }



下面是国外的一篇文章说明。
Hey Chris:
On Wed, Jan 26, 2005 at 12:28:19PM -0500, csnyder wrote:
>
> <?php
> // process form
> ...
> // redirect to results page
> header( 'HTTP/1.1 303 See Other' );
> header( 'Location: result.html' );
> exit( 'Form submitted, <a href="result.html">continue</a>.' );
> ?>
Good point. But some feedback here. The optimail syntax is:
<?php
// process form
// ...
// redirect to results page
header('Status: 303 See Other' );
header('Location: //www.jb51.net/result.html');
?>
Here's why...
Using "Status:" in the header is better because the resulting headers from
Apache are more correct:
HTTP/1.1 303 See Other
instead of
HTTP/1.1 303
Additionally, one doesn't really know which version of HTTP is being used,
so why potentially cause problems by trying to guess.
The specs say location headers must have a complete URI in them, not just
the path.
Lastly, you don't want any output after the location header.
Later,
--Dan

相关文章

PHP截取指定图片大小的方法

本文实例讲述了PHP截取指定图片大小的方法。分享给大家供大家参考。具体分析如下: imagecopyresampled($newim, $im, 0, 0, 7, 174, 120, 4...

php实现读取手机客户端浏览器的类

本文实例讲述了php实现读取手机客户端浏览器的类。分享给大家供大家参考。具体分析如下: 这里介绍的手机信息函数类有取手机号码,浏览器报头信息,取得手机类型,取得手机IP等功能。 复制代码...

phplist及phpmailer(组合使用)通过gmail发送邮件的配置方法

本文实例讲述了phplist及phpmailer通过gmail发送邮件的配置方法。分享给大家供大家参考,具体如下: 一般来说,只要你使用的不是gmail邮箱,那么利用phplist发送邮...

php,ajax实现分页

自己总结了些屁经验 1.用ajax post数据到后台页面后,接着要重新连接数据库,别以为用之前的session连接过就可以了 2.为了处理返回乱码的问题,我添加了header...

php中try catch捕获异常实例详解

本文实例讲述了php中try catch捕获异常。分享给大家供大家参考。具体方法分析如下: php中try catch可以帮助我们捕获程序代码的异常了,这样我们可以很好的处理一些不必要的...