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

Chipo ·
更新时间:2024-09-20
· 818 次阅读

跳转核心代码实现。
代码如下:
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: https://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中强制下载文件的代码(解决了IE下中文文件名乱码问题)php下载文件源代码(强制任意文件格式下载)php实现从ftp服务器上下载文件树到本地电脑的程序PHP/ThinkPHP实现批量打包下载文件的方法示例PHP 下载文件时自动添加bom头的方法实例PHP 下载文件时如何自动添加bom头及解释BOM头和去掉bom头的方法php实现SAE上使用storage上传与下载文件的方法PHP实现从远程下载文件的方法php+js实现的无刷新下载文件功能示例



response PHP

需要 登录 后方可回复, 如果你还没有账号请 注册新账号