Moodle 1.6


Multibyte File Name.gif

下記の場合、Moodle設定ファイル「config.php」の中に後述の設定追加およびプログラムの修正をお試しください。

  1. 日本語フォルダ名のフォルダを作成する (例 日本語フォルダ)
  2. 日本語ファイル名のファイルをアップロードする (例 日本語テキスト.txt)
  3. アップロードした日本語ファイル名のファイルをInternet Explorerでダウンロードする

config.phpに記述する設定内容

$CFG->unicodedb = true;
$CFG->unicodecleanfilename = true;

プログラム「moodle/file.php」の修正

修正対象プログラム: moodle/file.php
修正箇所 :149行目
備考:Internet Explorerで日本語ファイル名ファイルをダウンロードするため

  • 変更前
    $filename = $args[count($args)-1];
    send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
  • 変更後
   $filename = $args[count($args)-1];
  $ua = $_SERVER['HTTP_USER_AGENT'];
   if (strstr($ua, "MSIE") && !strstr($ua, 'Opera')) {
      $filename = mb_convert_encoding($filename, "SJIS", get_string('thischarset'));
   } elseif (strstr($ua, "Safari")) {
      if (get_string('thischarset') == "UTF-8") {
         $filename = "";
      } else {
         $filename = preg_replace('/[^\.a-zA-Z\d\_-]/', '_', $filename);
      }
   } else {
      $filename = mb_convert_encoding($filename, "UTF-8", get_string('thischarset'));
   }
   $filename = str_replace('#', '%23', $filename);
   send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);

プログラム「lib/filelib.php」の修正 - Internet Explorerで日本語ファイル名ファイルをダウンロードするため

修正対象プログラム: lib/filelib.php
修正箇所 :247行目

  • 変更前
    if ($forcedownload) {
       @header('Content-Disposition: attachment; filename='.$filename);
    } else {
       @header('Content-Disposition: inline; filename='.$filename);
    }


  • 変更後
    if ($forcedownload) {
       @header('Content-Disposition: attachment; filename="' . $filename . '"');
    } else {
       @header('Content-Disposition: inline; filename="' . $filename . '"');
    }

関連情報