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+apc+ajax实现的ajax_upload上传进度条代码

PHP+apc+ajax实现的ajax_upload上传进度条代码

本文实例讲述了PHP+apc+ajax实现的ajax_upload上传进度条代码。分享给大家供大家参考,具体如下: 上传进度条是怎么实现的呢?原理是怎么样的呢?当我们浏览...

PHP 之Section与Cookie使用总结

SESSION与COOKIE区别:   Session 将信息保存在服务器上.服务器在接受到唯一的SESSION_ID后,根据这个ID获取相关数据,然后将信息传递到客户端(浏览器).  ...

php批量删除超链接的实现方法

清除掉一段html文本内容中的超链接最常见的写法可以如下: 复制代码 代码如下:$str=preg_replace("/<a[^>]*href=[^>]*>|&l...

php数组使用规则分析

本文实例分析了php中数组的使用规则。分享给大家供大家参考。具体分析如下: 数组在php中处于灰常重要的地位。字符串、图片、数码、视频等值都以数组的形式存在,所以了解清楚数组的各种规则十...

PHP常用操作类之通信数据封装类的实现

PHP常用操作类之通信数据封装类的实现

前言 本文主要给大家介绍了关于PHP常用操作类之通信数据封装类实现的相关内容,分享出来供大家参考学习,下面话不多说,来一起看看详细的介绍: 必要性 不管在B/S架构中,还是C/S架构中...