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

相关文章

异步加载技术实现当滚动条到最底部的瀑布流效果

异步加载技术实现瀑布流效果。当滚动条到最底部的时候触发一个事件,这个事件写入$.get()事件,向内部程序页传递类别id和页码,程序将会返回那个类别下的相对页的产品列表,如果程序查询当前...

PHP附件下载中文名称乱码的解决方法

本文实例讲述了PHP附件下载中文名称乱码的解决方法。分享给大家供大家参考,具体如下: PHP中,如果要下载的文件名称为中文,则会出现文件标题乱码。 此时就需要对标题进行编码,也就是说先进...

PHP中include和require的区别实例分析

先编辑command.php文件 echo 'hello'.PHP_EOL; 然后编辑console.php文件 for($i=1;$i<=3;++$i){ requ...

PHP转盘抽奖接口实例

本文实例讲述了PHP转盘抽奖接口的实现方法。分享给大家供大家参考。具体如下: 这里的转盘抽奖随机返回一个转盘角度,概率可自己定义 lottery_get.php接口文件如下: 复制代码...

php校验公钥是否可用的实例方法

ssh如何利用RSA公钥进行远程登录验证 1、本地机器生成密钥 $ssh-keygen -t rsa 生成基于ssh协议第二版密钥,如果还是用rsa1,该升级了。 2、复制生...