Re: 怎樣讓點了連結後變下載?

看板Web_Design作者 (java)時間19年前 (2004/12/04 19:23), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ 引述《ificould (我也不過是泛泛之輩而已)》之銘言: : 像是放文字檔txt 之類的.. : 點了那個連文字檔的連結後 都會自動變成瀏覽器開啟檔案... : 有語法能讓他改成下載嗎? 不要直接開啟 說說看你是在什麼環境 如果是純html網頁 我不知道 如果是在php我知道 可以用這個例子 先另外寫一php網頁 <?php $file = "http:// localhost/file-to-download.txt"; //放你要給下載的東西 header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($file)); @readfile($file); ?> 當你連到這頁時 就會自動要求你做下載確認 如果是其他網頁如 asp , jsp 一定也有相同或類似的做法 找找看吧! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.214.32
文章代碼(AID): #11iPuLKj (Web_Design)