Программирование > PHP

UebiMiau

(1/1)

ferryman:
Столкнулся с проблемой. При чтениии письма с аттачем в  в UebiMiau невозможно сохранить рускоязычный файл.
Аттач хранится на диске в формате (пр. 47f4e4ee326e28e4132f228a76629fcb_24064_Документ Microsoft Word.doc) md5($attach[\'boundary\'])."_".$attach[\'size\']."_".$attach[\'name\']
и отдается скриптом, вот кусок
$fp = fopen($attach["filename"], "rb");
        fseek($fp,0,SEEK_END);
        $size = ftell($fp);
        rewind($fp);
        $stream = fgets($fp,$size);
        fclose($fp);

        $disposition = ($_GET[\'down\'] != 1) ? "inline" : "attachment";
        $type = (!preg_match("/[a-z]+\\/[a-z-]+/i", $attach["content-type"])) ? "application/octet-stream" : $attach["content-type"];

        Header("Content-Type: ".$type."; name=\\"".$attach["name"]."\\"\\r\\n");
        Header("Content-Length: ".$size."\\r\\n");
        Header("Content-Disposition: ".$disposition."; filename=\\"".$attach["name"]."\\"\\r\\n");
echo $stream;

В опере и Мозиле работает отлично, но в IE - отказывается.
Может кто сталкивался с проблемой, или натолкните на мысль, как побороть?

CGVictor:
ferryman
[p]utf8_encode[/p] / [p]mb_convert_encoding[/p] для имени?

ferryman:
Спасибо, но уже разобрался. на php.net нашел и изменил. теперь работает нормально и в осле

$disposition = (!isset($down)) ? "inline" : "attachment";
        $type = (!preg_match("/[a-z]+\\/[a-z-]+/i", $attach["content-type"])) ? "application/octet-stream" : $attach["content-type"];

        header("Pragma: public");
        header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: private");
        header("Content-Transfer-Encoding: binary");

        Header("Content-Type: $type\\r\\n");
        Header("Content-Length: ".$size."\\r\\n");

        if (strstr($_SERVER[\'HTTP_USER_AGENT\'], "MSIE")) {
        $iefilename = preg_replace(\'/\\./\', \'%2e\', $attach["name"], substr_count($attach["name"], \'.\') - 1);
        header("Content-Disposition: attachment; filename=\\"$iefilename\\"");

        }else{
        Header("Content-Disposition: $disposition; filename=\\"".$attach["name"]."\\"\\r\\n");
        }
        echo $stream;

CGVictor:
[off]ferryman
Хм...первый раз вижу такое, но если работает - значит, так надо :) [/off]

Навигация

[0] Главная страница сообщений

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 
Перейти к полной версии