[請益] header無法下載檔案
請問各位
以下是我從網路上找到的標準範例,
不知哪邊錯誤,我的頁面都無法成功下載檔案呢。
PS. 確定檔案有產生
$handle = fopen("file.txt", "w");
fwrite($handle, "text1.....");
fclose($handle);
$url = "http://localhost/file.txt";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('file.txt'));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize('file.txt'));
readfile('file.txt');
exit;
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.43.97.245
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1445427713.A.83B.html
→
10/21 21:18, , 1F
10/21 21:18, 1F
→
10/21 21:19, , 2F
10/21 21:19, 2F
→
10/21 21:19, , 3F
10/21 21:19, 3F
→
10/22 21:42, , 4F
10/22 21:42, 4F
→
10/23 11:02, , 5F
10/23 11:02, 5F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章