看板 PHP 關於我們 聯絡資訊
<?php header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', false); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' .mb_convert_encoding($fname,'big5','UTF-8').'"'); header('Content-Transfer-Encoding: binary'); readfile($fpath); exit; //$fname 為 希望的檔案名稱 //mb_convert_encoding 將其從 big5 轉為 utf8 //$fpath 為 檔案路徑 ?> ※ 引述《newyellow (newyellow)》之銘言: : 請問要怎麼樣讓 下載檔案時 : 檔案的名稱可以即時改變? : 例如說 : 有一個檔案 phpDocument.doc : 然後可以讓使用者下載 phpDocument.doc 時 : 載下來的檔名是其他的名稱 比如說 php文件.doc : 因為在做後台時 : 讓使用者上傳檔案 用英文存檔比較不會有問題 : 再加上為了避免使用者上傳同檔名檔案會蓋掉 : 通常上傳時都會讓檔名加上一些有的沒有 : 但我想要讓使用者在下載的時候可以更直覺 : 所以想要這樣子做 : 請問這樣子要怎麼做呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.101.9.24
newyellow:非常謝謝您 !!! :) 08/12 23:59
TaiKeDa:別客氣 :) 08/13 00:30