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漏洞之跨网站请求伪造与防止伪造方法

伪造跨站请求介绍伪造跨站请求比较难以防范,而且危害巨大,攻击者可以通过这种方式恶作剧,发spam信息,删除数据等等。这种攻击常见的表现形式有:   伪造链接,引诱用户点击,或是让用户在不...

php实现以只读方式打开文件的方法

本文实例讲述了php实现以只读方式打开文件的方法。分享给大家供大家参考。具体分析如下: php中可以通过fopen()打开一个文件,第二个参数设置为"r"表示已只读方式打开,函数返回一个...

php 利用socket发送HTTP请求(GET,POST)

  今天给大家带来的是如何利用socket发送GET,POST请求。我借用燕十八老师封装好的一个Http类给进行说明。   在日常编程中相信很多人和我一样大部分时间是利用浏览器向服务器提...

PHP中PDO的错误处理

PHP中PDO的错误处理

面向对象的方式 先看看如果连接错误等的处理,PHP中PDO的错误处理,使用面向对象的方式来处理: 复制代码 代码如下: <?php try {  $db = new PDO('my...

php获取网站根目录物理路径的几种方法(推荐)

在PHP中获取网站根目录物理路径。 在php程序开发中经常需要获取当前网站的目录,我们可以通过常量定义获取站点根目录物理路径,方便在程序中使用。 下面介绍几种常用的获取网站根目录的方法。...