Re: [請益] 存成 txt 檔

看板PHP作者 (總是不知所措)時間17年前 (2008/07/08 18:31), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/7 (看更多)
※ 引述《Joe8 (Beautiful Stranger)》之銘言: : 請教各位一個問題唷 : 我想把資料寫入txt檔後 讓使用者下載該文字檔 : 寫入這部份已經完成,但是下載怎麼弄都會被瀏覽器直接讀取(開啟)出來 : 無法像存成xls那樣能以"儲存檔案"的方式讓使用者下載... : 我試過 : 1.用readfile() : 2.直接用超連結txt檔案 : 結果都無法達到目標 : 有沒有人可以給點方向,謝謝! 試試以下, header 前不可有任何的 html output. $txt_data = 'text file'; header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=xxxx.txt"); header("Cache-Control: cache, must-revalidate"); header("Pragma: no-cache"); header("Expires: 0"); echo $txt_data; exit; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.190.50

07/09 00:02, , 1F
挖屋 成功了! 感謝您...不過XLS無法存中文字Orz
07/09 00:02, 1F
文章代碼(AID): #18Sq7qKG (PHP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
以下文章回應了本文
完整討論串 (本文為第 4 之 7 篇):
文章代碼(AID): #18Sq7qKG (PHP)