2010-07-23 58 views

回答

7

重定向到其發出以下標題的頁面:

header("Content-Disposition: attachment; filename=$filename"); 
header("Content-Length: $length"); 

this post有關$filename的限制。

響應安德烈的回答,PHP相當於重定向消息後的X秒將是編輯

header("Refresh: 2; url=start_download.php"); 

(雖然你應該正式指定一個完整的URL,我認爲),其中start_download。 PHP將包含上面的兩行。

2

首先顯示帶有一些內容的頁面(請等待,等等等等),然後重定向到文件本身或輸出文件的腳本。 重定向要麼通過元標記或JavaScript實現:

  1. HTML:<meta http-equiv="refresh" content="5;url=http://example.com/foo.zip" />其中«5»以秒爲
  2. JS在頁面加載:setTimeout("location.href=http://example.com/foo.zip", 5000)其中«5000»以毫秒爲單位。

如果您選擇通過php腳本輸出文件,請按照mvds的答案。

+0

好點,以爲它只是關於瀏覽器對話框。 – mvds 2010-07-23 17:43:19

相關問題