|
wamp环境下,mediawiki上传文件的文件名含有汉字时,上传到服务器存储的文件名是乱码,下面是解决办法:
(参考:http://d.hatena.ne.jp/akaiwa/20080604/1212590583)
修改mediawiki/includes/filerepo/FSRepo.php文件:
function publishBatch( $triplets, $flags = 0 )函数中
- $dstPath = "{$this->directory}/$dstRel";
- $archivePath = "{$this->directory}/$archiveRel";
-
- //fix bug while upload file with chinese character in filename
- $dstPath = mb_convert_encoding( $dstPath, 'GBK', 'auto');
- $archivePath = mb_convert_encoding( $archivePath, 'GBK', 'auto');
-
- // Archive destination file if it exists
- if( is_file( $dstPath ) ) {
复制代码 function deleteBatch( $sourceDestPairs )函数中- foreach ( $sourceDestPairs as $pair ) {
- list( $srcRel, $archiveRel ) = $pair;
- $srcPath = "{$this->directory}/$srcRel";
- $archivePath = "{$this->deletedDir}/$archiveRel";
-
- //fix bug while upload file with chinese character in filename
- $srcPath = mb_convert_encoding( $srcPath, 'GBK', 'auto');
- $archivePath = mb_convert_encoding( $archivePath, 'GBK', 'auto');
-
- $good = true;
复制代码 function getFileProps( $virtualUrl )函数中
- function getFileProps( $virtualUrl ) {
- $path = $this->resolveVirtualUrl( $virtualUrl );
- //fix bug while upload file with chinese character in filename
- return File::getPropsFromPath( mb_convert_encoding( $path, 'GBK', 'auto') );
- //original code
- //return File::getPropsFromPath( $path );
- }
复制代码 |
|