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使用HTML5 FileApi实现Ajax上传文件功能示例

PHP使用HTML5 FileApi实现Ajax上传文件功能示例

本文实例讲述了PHP使用HTML5 FileApi实现Ajax上传文件功能。分享给大家供大家参考,具体如下: FileApi是HTML5的一个新特性,有了这个新特性,js就可以读取本地的...

php获取用户IPv4或IPv6地址的代码

其实这个很简单,只不过我一直想用 ipv6-test 的API做一个获取用户IP地址的东西……无奈JSON获取到的只是本机服务器的IP。算了,不研究了,何况人家提供的widget也挺好用...

火车头discuz6.1 完美采集的php接口文件

PS:对原文件的修改较大,程序中注释已经很详尽,这里就不多说了。 复制代码 代码如下:<?php // header('Content-Type:text/html;charset...

asp函数split()对应php函数explode()

<?php //利用 explode 函数分割字符串到数组 $source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离...

php获取根域名方法汇总

本文实例汇总了php获取根域名方法,分享给大家供大家参考。具体实现方法如下: 如果你只简单获取当前访问你页面的域名,我们只需要使用php中的函数HTTP_HOST就可以搞定了,如果是提取...