環境
FreeBSD 5.21
PHP 4.3.10
phpMyAdmin 2.6.1 rc1
phpbb2 2.3.11
attchment mod 2.3.10
請教各位前輩高手,我目前遇到的問題是attchmet mod可以上傳中文檔名,因為我用utf-8的環境,但要下載檔案時,fire fox可以正確下載,IE卻會變成英文字.。
例如:"你好.doc"可以成功上傳,firefox可以正確下載"你好.doc",但是用IE下載會變成"CA4DA1CV.",副檔名不見了。
嘗試開關IE有關URL UTF-8的選項,仍無法解決。
請各位撥冗點撥一下修改方向,謝謝。
[問題] 請教 attachement mod與IE的問題:下載時附檔名不見
版主: 版主管理群
真是如此!謝謝您的回答,一直懷疑自己是否安裝時有改錯行句。
不過我找到download.php,約莫180行左右:
發現它有對IE與opera的特殊條件:
// Correct the mime type - we force application/octetstream for all files, except images
// Please do not change this, it is a security precaution
if (!strstr($attachment['mimetype'], 'image'))
{
$attachment['mimetype'] = ($browser_agent == 'ie' || $browser_agent == 'opera') ? 'application/octetstream' : 'application/octet-stream';
}
如果把這個條件mark起來,
接著在下方約190行
header('Content-Transfer-Encoding: none');
下面加上:
header("Content-type: application/octetstream");
這樣會出現副檔名,但"你好.doc",仍是像"DAB3TMN.doc",但至少副檔名出現了;且firefox不受影響。
只是這樣做是否有原作者提及的security precaution安全問題,還得請大家再確認。
再次謝謝您撥冗回應與協助!您提供的方式真幫了很大的忙!檔名已經完全正常!
不過我找到download.php,約莫180行左右:
發現它有對IE與opera的特殊條件:
// Correct the mime type - we force application/octetstream for all files, except images
// Please do not change this, it is a security precaution
if (!strstr($attachment['mimetype'], 'image'))
{
$attachment['mimetype'] = ($browser_agent == 'ie' || $browser_agent == 'opera') ? 'application/octetstream' : 'application/octet-stream';
}
如果把這個條件mark起來,
接著在下方約190行
header('Content-Transfer-Encoding: none');
下面加上:
header("Content-type: application/octetstream");
這樣會出現副檔名,但"你好.doc",仍是像"DAB3TMN.doc",但至少副檔名出現了;且firefox不受影響。
只是這樣做是否有原作者提及的security precaution安全問題,還得請大家再確認。
再次謝謝您撥冗回應與協助!您提供的方式真幫了很大的忙!檔名已經完全正常!
- mika14913131
- 星球普通子民

- 文章: 1
- 註冊時間: 2006-07-31 16:49
[反應] ㄧ樣的問題
嗯嗯 最近在架設論壇 也遇到同樣的問題
找到原因了
因為IE預設會用BIG5去讀檔
FireFox比較聰明 會知道檔名是UTF8
所以在的下面再多家ㄧ行判斷
樓上說的security precaution可以不用註解掉
即可中文檔名正常運作
找到原因了
因為IE預設會用BIG5去讀檔
FireFox比較聰明 會知道檔名是UTF8
所以在
代碼: 選擇全部
$real_filename = html_entity_decode(basename($attachment['real_filename']));代碼: 選擇全部
$real_filename = ($browser_agent == 'ie' || $browser_agent == 'opera')? iconv("UTF-8","BIG5",$real_filename):$real_filename; 樓上說的security precaution可以不用註解掉
即可中文檔名正常運作
