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使用DES进行加密与解密的方法详解

DES是一种标准的数据加密算法,关于这个算法的详细介绍可以参考wiki和百度百科: wiki百科    百度百科 php中有一个扩展可以支持DES的加密算法...

浅析php与数据库代码开发规范

1、PHP中对各类变量内容的命名规范  (1)目录命名、文件命名、局部变量命名: 使用英文名词、动词,以下划线作为单词的分隔,所有字母均使用小写 目录:upload、templ...

php自定义中文字符串截取函数substr_for_gb2312及substr_for_utf8示例

本文实例讲述了php自定义中文字符串截取函数substr_for_gb2312及substr_for_utf8用法。分享给大家供大家参考,具体如下: /* *gb2312中文字符串截...

简要剖析PHP的Yii框架的组件化机制的基本知识

简要剖析PHP的Yii框架的组件化机制的基本知识

组件是 Yii 应用的主要基石。是 yii\base\Component 类或其子类的实例。三个用以区分它和其它类的主要功能有: 属性(Property) 事件(Event)...

php如何解决无法上传大于8M的文件问题

开发一个文件上传共享网站,曾想使用下面的代码实现文件上传的功能: 复制代码 代码如下: <form enctype="multipart/form-data" action="ad...