Skip to content

windows10+Edgeで日本語名ファイル,ダウンロード文字化け対応 #126

Description

@akagane99

windows10+Edgeで日本語名ファイルをダウンロードすると、ファイル名が文字化けします。
下記で対応しました。
ご報告まで。

HTTP_USER_AGENT (windows10+Edge)

HTTP_USER_AGENT
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586  

修正前

/html/webapp/components/uploads/View.class.php

header("Content-disposition: inline; filename=\"".$filename."\"");

修正後

        } else {
            // 上記以外(Mozilla, NetScape, GoogleChrome, Edge)
            //header("Content-disposition: inline; filename=\"".$filename."\"");
            header('Content-Disposition: attachment; filename*=UTF-8\'\''.rawurlencode($filename));
        }

動作確認

  • windows10
    • Chrome 日本語ファイル名ダウンロードok
    • Edge 日本語ファイル名ダウンロードok
    • FireFox ok
    • IE11 ok

参考URL

▼ PHPでダウンロードさせるファイル名がIEで文字化けする件 - Qiita
http://qiita.com/takehironet/items/79c025e4140e29c57abe
⇒ IEと書いてあるけどEdgeにも有効だった

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions