php download.php實現(xiàn)代碼 跳轉(zhuǎn)到下載文件(response.redirect)
更新時間:2009年08月26日 00:03:06 作者:
一直對php不太熟悉,今天需要類型asp的 response.redirect語句,但一直沒有很好的解決方法。下面是問了朋友才知道的。
跳轉(zhuǎn)核心代碼實現(xiàn)。
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: http://www.dbjr.com.cn/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
復制代碼 代碼如下:
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: http://www.dbjr.com.cn/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實現(xiàn)遠程下載文件到本地
- php實現(xiàn)當前頁面點擊下載文件的實例代碼
- php中強制下載文件的代碼(解決了IE下中文文件名亂碼問題)
- php下載文件源代碼(強制任意文件格式下載)
- php實現(xiàn)從ftp服務器上下載文件樹到本地電腦的程序
- PHP/ThinkPHP實現(xiàn)批量打包下載文件的方法示例
- PHP 下載文件時自動添加bom頭的方法實例
- PHP 下載文件時如何自動添加bom頭及解釋BOM頭和去掉bom頭的方法
- php實現(xiàn)SAE上使用storage上傳與下載文件的方法
- PHP實現(xiàn)從遠程下載文件的方法
- php+js實現(xiàn)的無刷新下載文件功能示例
相關(guān)文章
PHP數(shù)據(jù)對象PDO操作技巧小結(jié)
這篇文章主要介紹了PHP數(shù)據(jù)對象PDO操作方法,結(jié)合實例形式總結(jié)分析了php基于pdo的各種常見數(shù)據(jù)庫操作相關(guān)技巧與注意事項,需要的朋友可以參考下2016-09-09gearman中任務的優(yōu)先級和返回狀態(tài)實例分析
這篇文章主要介紹了gearman中任務的優(yōu)先級和返回狀態(tài),結(jié)合實例形式分析了gearman任務的優(yōu)先級以及獲取返回狀態(tài)相關(guān)操作技巧,需要的朋友可以參考下2020-02-02Windows下安裝PHP單元測試環(huán)境PHPUnit圖文教程
這篇文章主要介紹了Windows下安裝PHP單元測試環(huán)境PHPUnit圖文教程,按照本文操作即可在Windows下安裝成功PHPUnit,需要的朋友可以參考下2014-10-10php實現(xiàn)接口api數(shù)據(jù)簽名及驗簽
api數(shù)據(jù)簽名作用就是通過使用簽名可以驗證數(shù)據(jù)在傳輸過程中是否被篡改或修改,下面小編就來為大家介紹一下php如何實現(xiàn)接口api數(shù)據(jù)簽名及驗簽吧2023-11-11