php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com5年前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数据库解决方案分析介绍

常见PHP数据库解决方案分析介绍

我们在使用PHP连接数据库的时候会遇到很多问题,文章这里揭露PHP应用程序中出现的常见数据库问题 —— 包括数据库模式设计、数据库访问和使用数据库的业务逻辑代码 —— 以及它们的解决方案...

php结合web uploader插件实现分片上传文件

最近研究了下大文件上传的方法,找到了webuploader js 插件进行大文件上传,大家也可以参考这篇文章进行学习:《Web Uploader文件上传插件使用详解》 使用  ...

php递归列出所有文件和目录的代码

<?php /*我的程序在国外的SREVER上,自己编的程序存放到哪,我很难记清。 所以编了一个简单的目录递归函数,查看我的程序,很方便的。 */ function tree($d...

获取远程文件大小的php函数

复制代码 代码如下:<?php function getFileSize($url){ $url = parse_url($url); if($fp = @fsockopen($u...

优化PHP程序的方法小结

1. If a method c++an be static, declare it static. Speed improvement is by a factor of 4. 如果一...