欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-09 08:26:11
跳转核心代码实现。复制代码 代码如下:if (isset($link))         &...
跳转核心代码实现。
复制代码 代码如下:

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