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

相关文章

PHP5.5在windows安装使用memcached服务端的方法

PHP5.5在windows安装使用memcached服务端的方法

  PHP5.5 在windows下安装 memcached 的方法   下载服务端资源   http://download.csdn.net/detail/zsjangel/71047...

PHP实现从上往下打印二叉树的方法

本文实例讲述了PHP实现从上往下打印二叉树的方法。分享给大家供大家参考,具体如下: 问题 从上往下打印出二叉树的每个节点,同层节点从左至右打印。 解决思路 每层树从左到右打印,所以需要将...

PHP实现对数组分页处理实例详解

本文实例讲述了PHP实现对数组分页处理方法。分享给大家供大家参考,具体如下: 最近用到了用数组数据分页,这里整理了一下,具体代码如下: <?php class Pagi...

php获取图片信息的方法详解

本文实例讲述了php获取图片信息的方法。分享给大家供大家参考,具体如下: getimagesize() 函数将测定任何 GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,...

用PHP ob_start()控制浏览器cache、生成html实现代码

输出控制函数不对使用 header() 或 setcookie(), 发送的文件头信息产生影响,只对那些类似于 echo() 和 PHP 代码的数据块有作用。 我们先举一个简单的例子,让...