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

相关文章

示例详解Laravel重置密码代码重构

1、首先确定重置密码的路由 我们在安装好laravel的时候默认生成的重置密码是在用户未登录的情况下进行的。所以使用原来的控制器是不可行的,并且原有的重置密码,并不需要查看原始密码是否...

PHP 采集获取指定网址的内容

参考别人想法变成自己的想法,你会发现慢慢下来以后你就拥有了临时解决很多问题的思路与方法。复制代码 代码如下:<?php /* 功能:获取页面内容,存储下来阅读; lost63 */...

php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法

本文实例讲述了php使用ZipArchive提示Fatal error: Class ZipArchive not found in的解决方法。分享给大家供大家参考。具体如下: ZipA...

php上传图片到指定位置路径保存到数据库的具体实现

1.conn.php 复制代码 代码如下: <? $host="localhost"; //数据库服务器名称 $user="root"; //用户名 $pwd="1721"; //...

PHP文件操作实例总结

PHP文件操作实例总结

本文实例总结了PHP文件操作。分享给大家供大家参考,具体如下: 操作文件的常用方法: flie_put_contents(url,str); file_get_contents(url...