PHP生成下載文件,然后重定向我有一個PHP應用程序,它創建一個CSV文件,該文件被迫使用頭下載。下面是代碼的相關部分:header('Content-Type: application/csv'); header("Content-length: " . filesize($NewFile)); header('Content-Disposition:
attachment; filename="' . $FileName . '"'); echo $content;exit();我想做的是,在生成文件并發送下載提示后,將用戶重定向到一個新頁面。只是添加header("Location: /newpage")一直到最后都沒有起作用,我期待著,所以我不知道該如何調整這個。
3 回答

白衣非少年
TA貢獻1155條經驗 獲得超0個贊
[a href="create_csv.php"]here[/a]
.
HTML: [meta http-equiv="refresh" content="5;url=http://site/create_csv.php"]
JavaScript: location.href = 'http://site/create_csv.php';
如果: [iframe src="create_csv.php"][/iframe]

弒天下
TA貢獻1818條經驗 獲得超8個贊
header('Set-Cookie: fileLoading=true');
setInterval(function(){ if ($.cookie("fileLoading")) { // clean the cookie for future downoads $.removeCookie("fileLoading"); //redirect location.href = "/newpage"; }},1000);
- 3 回答
- 0 關注
- 687 瀏覽
添加回答
舉報
0/150
提交
取消