松鼠郵件下載檔案亂碼問題
因為在ie下用squirrel mail 收附加檔案
會出現亂碼而小第也自已做了一個utf-8的語系~不過還是宣告失敗
自已做的utf-8 語系雖然收信等等都ok不過收別人寄來的信幾都是都big5 所以這個方法也是不work的
後來去分析了一下有關header封包中的filename的記錄如下
Content-dis postition: inline ; filename="%20%20%%20%20%%20%2020050816%BA%F4%B8%F4%B8%EA%B7%BD%B3W%B9%BA.xls"rnrn
然後去程式中找有關header的程式
grep -R SendDownloadHeader *
發現在mine.php中有提到
mime.php: * function SendDownloadHeaders – send file to the browser
mime.php:function SendDownloadHeaders($type0, $type1, $filename, $force, $filesize=0) {
mime.php:} // end fn SendDownloadHeaders
so 看了一下mine.php
如下:
if ($isIE) {
$filename=rawurlencode($filename);
header ("Pragma: public");
header ("Cache-Control: no-store, max-age=0, no-cache, must-revalidate"); // HTTP/1.1
header ("Cache-Control: post-check=0, pre-check=0", false);
header ("Cache-Control: private");
//set the inline header for IE, we'll add the attachment header later if we need it
header ("Content-Disposition: inline; filename=$filename");
}
if (!$force) {
// Try to show in browser window
header ("Content-Disposition: inline; filename="$filename"");
header ("Content-Type: $type0/$type1; name="$filename"");
} else {
// Try to pop up the "save as" box
// IE makes this hard. It pops up 2 save boxes, or none.
// http://support.microsoft.com/support/kb/articles/Q238/5/88.ASP
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;260519
// But, according to Microsoft, it is "RFC compliant but doesn't
// take into account some deviations that allowed within the
// specification." Doesn't that mean RFC non-compliant?
// http://support.microsoft.com/support/kb/articles/Q258/4/52.ASP
// all browsers need the application/octet-stream header for this
header ("Content-Type: application/octet-stream; name="$filename"");
// http://support.microsoft.com/support/kb/articles/Q182/3/15.asp
// Do not have quotes around filename, but that applied to
// "attachment"… does it apply to inline too?
header ("Content-Disposition: attachment; filename="$filename"");
if ($isIE && !$isIE6) {
…….
程式自行的幫ie 去判斷~~
不過ie不吃這套`~so把
if ($isIE) {
//$filename=rawurlencode($filename); <==這行註解掉
header ("Pragma: public");
就ok了~~
不知道之前有沒有人發表過~~提出來給有用小松鼠的人參考
我也遇到这个问题了,在网上搜到了你的帖子,受益了.谢谢!
^^ 不會 很高興有幫到你