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操作文件的一些基本函数使用示例

PHP操作文件的一些基本函数使用示例

在对文件进行操作时,不仅可以对文件中的数据进行操作,还可以对文件本身进行操作。例如复制文件、删除文件、截取文件及为文件重命名等操作。在PHP中已经提供了这些文件处理方式的标准函数,使用也...

php获取网站根目录物理路径的几种方法(推荐)

在PHP中获取网站根目录物理路径。 在php程序开发中经常需要获取当前网站的目录,我们可以通过常量定义获取站点根目录物理路径,方便在程序中使用。 下面介绍几种常用的获取网站根目录的方法。...

php PDO实现的事务回滚示例

本文实例讲述了php PDO实现的事务回滚。分享给大家供大家参考,具体如下: $servername="localhost"; $username="root"; $password...

php图像处理类实例

本文实例讲述了php图像处理类。分享给大家供大家参考。具体如下: <?php /** * Image 类 */ class Image { /** * @var...

PHP使用PDO操作sqlite数据库应用案例

本文实例讲述了PHP使用PDO操作sqlite数据库。分享给大家供大家参考,具体如下: 1、需求: 已知: 1)、一个json文件,里面是一个二维数组,数组解析出来为: array...