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实现读取文件夹及批量重命名文件操作示例

本文实例讲述了PHP实现读取文件夹及批量重命名文件操作。分享给大家供大家参考,具体如下: 以读取从网上下载的评书解压后的文件夹为例,并批量重命名 文件夹内容如下,现在使用php读取这个...

php实现的支持imagemagick及gd库两种处理的缩略图生成类

本文实例讲述了php实现的支持imagemagick及gd库两种处理的缩略图生成类及其用法实例,非常具有实用价值。分享给大家供大家参考。具体如下: 一、功能: 1.按比例缩小/放大 2....

Windows2003下php5.4安装配置教程(IIS)

Windows2003下php5.4安装配置教程(IIS)

本文与《Windows2003下php5.4安装配置教程(Apache2.4)》(点击打开链接)为姊妹篇,只是php所用的服务器有点不同,这里一个是Apache2.4,一个是Window...

php中通过eval实现字符串格式的计算公式

有时候我们对每一种产品都有一个提成公式,而这个计算提成的公式是以字符串格式存在表中的当我们用这个计算公式时,他并不像我们写的:$a=2+3*5;这样简单的能计算出结果,而它是个字符串.所...

如何解决PHP获取不到SESSION信息之一般情况

一、检查 php.ini vim /etc/php.ini 检查这几项: session.save_handler = files // session 的存储类型; se...