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 at(@)符号的用法简介

下面介绍一下它的用法. 例如: 复制代码 代码如下: function db_connect()//连接数据库 { @$db =mysql_connect('localhost','ro...

php检测图片主要颜色的方法

本文实例讲述了php检测图片主要颜色的方法。分享给大家供大家参考。具体实现方法如下: $i = imagecreatefromjpeg("image.jpg"); for ($x=0...

关于svn冲突的解决方法

1.在冲突文件上右键----edit conflicts-----然后手动修改文件冲突的红色地方,其他地方可以不用管。 2.修改完后保存。将本地和svn里面的文件都保存好。 3.再在冲突...

php查找字符串中第一个非0的位置截取

php查找字符串中第一个非0的位置截取

话不多说,请看代码: $str = '00000000000000000000000000000000000000001234506'; $preg = '/[0]*/'; $res...

不要轻信 PHP_SELF的安全问题

复制代码 代码如下:<html> <body> <?php if (isset($_REQUEST['submitted']) && $_REQUEST['...