hostease主机优惠

Mediawiki中文技术论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10189|回复: 0

[技术文档] 修改mediawiki上传文件时文件名含有中文的乱码问题

[复制链接]
发表于 2011-12-29 10:53:28 | 显示全部楼层 |阅读模式
RAKsmart美国服务器
wamp环境下,mediawiki上传文件的文件名含有汉字时,上传到服务器存储的文件名是乱码,下面是解决办法:
(参考:http://d.hatena.ne.jp/akaiwa/20080604/1212590583)
修改mediawiki/includes/filerepo/FSRepo.php文件:
function publishBatch( $triplets, $flags = 0 )函数中

  1.         $dstPath = "{$this->directory}/$dstRel";
  2.         $archivePath = "{$this->directory}/$archiveRel";

  3.         //fix bug while upload file with chinese character in filename
  4.         $dstPath = mb_convert_encoding( $dstPath, 'GBK', 'auto');
  5.         $archivePath = mb_convert_encoding( $archivePath, 'GBK', 'auto');

  6.         // Archive destination file if it exists
  7.         if( is_file( $dstPath ) ) {
复制代码
function deleteBatch( $sourceDestPairs )函数中
  1. foreach ( $sourceDestPairs as $pair ) {
  2.         list( $srcRel, $archiveRel ) = $pair;
  3.         $srcPath = "{$this->directory}/$srcRel";
  4.         $archivePath = "{$this->deletedDir}/$archiveRel";

  5.         //fix bug while upload file with chinese character in filename
  6.         $srcPath = mb_convert_encoding( $srcPath, 'GBK', 'auto');
  7.         $archivePath = mb_convert_encoding( $archivePath, 'GBK', 'auto');

  8.         $good = true;
复制代码
function getFileProps( $virtualUrl )函数中

  1.         function getFileProps( $virtualUrl ) {
  2.         $path = $this->resolveVirtualUrl( $virtualUrl );
  3.         //fix bug while upload file with chinese character in filename
  4.         return File::getPropsFromPath( mb_convert_encoding( $path, 'GBK', 'auto') );
  5.         //original code
  6.         //return File::getPropsFromPath( $path );
  7. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

美国主机评测网站

Archiver|手机版|小黑屋|Mediawiki中文技术论坛

GMT+8, 2024-4-28 17:38 , Processed in 0.047987 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表