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 开发中加密的几种方法总结

1,使用crypt()函数进行加密 crypt()函数可以进行单项加密,具体语法如下: string crypt(string str[,tring salt]) 其中...

PHP排序算法之堆排序(Heap Sort)实例详解

PHP排序算法之堆排序(Heap Sort)实例详解

本文实例讲述了PHP排序算法之堆排序(Heap Sort)。分享给大家供大家参考,具体如下: 算法引进: 在这里我直接引用《大话数据结构》里面的开头: 在前面讲到 简单选择排序 ,它在待...

PHP中创建空文件的代码[file_put_contents vs touch]

I has passed a small test to check which function is faster to create a new file. file_put_co...

php json_encode值中大括号与花括号区别

1.当array是一个从0开始的连续数组时,json_encode出来的结果是一个由[]括起来的字符串 而当array是不从0开始或者不连续的数组时,json_encode出来的结果是一...

thinkphp jquery实现图片上传和预览效果

thinkphp jquery实现图片上传和预览效果

先上效果图: 那个file按钮样式先忽略 点击选择图片(浏览),随便选一张图片 js代码如下 //上传图片立即预览 function PreviewImage(imgFil...