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多维数组排序array详解

PHP数组Array按字段排序 /** * Sort array by filed and type, common utility method. * @param...

php 获取文件行数的方法总结

stream_get_line获取文件行数 <?php $file_path = 'xxx.txt'; //文件路径 $line = 0 ; //初始化行数 //...

连接到txt文本的超链接,不直接打开而是点击后下载的处理方法

服务器端两种处理方法,一个是apache或者iis or tomcat等服务器中进行设置,或者在程序中指定发送类型。 该信息属于http头部信息,php有直接进行头部信息操作的函数。 p...

SSI指令

什么是 SHTML 使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Inclu...

PHP转换文件夹下所有文件编码的实现代码

PHP转换文件夹下所有文件的编码 适合发布网站的其他编码版本 比如你有一个GBK版本 你想有一个UTF8版本 或者你只有GBK的源码 你想二次开发 但是你不想改变IDE的编码方式 你可以...