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脚本来实现WordPress中评论分页的功能

方法说明 首先来看看可能被用到的方法. 打开文件 wp-includes/link-template.php 你会发现 WordPress 2.7 多了 4 个针对评论分页的方法:...

PHP删除目录及目录下所有文件的方法详解

函数代码一:删除目录及目录下的所有文件复制代码 代码如下://循环删除目录和文件函数function delDirAndFile( $dirName ){if ( $handle = o...

php print EOF实现方法

我写段php代码如下: 复制代码 代码如下:<? if(test case) print<<<EOT <....html code....> EOF;...

PHP采集静态页面并把页面css,img,js保存的方法

本文实例讲述了PHP采集静态页面并把页面css,img,js保存的方法。分享给大家供大家参考。具体分析如下: 这是一个可以获取网页的html代码以及css,js,font和img资源的小...

php转换上传word文件为PDF的方法【基于COM组件】

本文实例讲述了php转换上传word文件为PDF的方法。分享给大家供大家参考,具体如下: 以前用过office组件转换上传文件word同时转换为html文件,这次要将word文件转换为p...