【CKFinder】解决上传中文名文件乱码和文件重命名的问题


在Windows Server 2003的服务器平台上,用CKFinder上传中文文件名的文件,上传后,文件名变成了乱码,导致文件链接找不到。


上传中文名文件乱码问题

在ckfinder/config.php中找到如下一段配置代码:

/*
If you have iconv enabled (visit http://php.net/iconv for more information),
you can use this directive to specify the encoding of file names in your
system. Acceptable values can be found at:
http://www.gnu.org/software/libiconv/

Examples:
$config['FilesystemEncoding'] = 'CP1250';
$config['FilesystemEncoding'] = 'ISO-8859-2';
*/
$config['FilesystemEncoding'] = 'UTF-8';

将UTF-8修改为GB2312,上传后文件名正确了,但在CKEditor中显示的链接出现乱码,因为CKEditor所在页面使用的字符集是UTF-8,未去细究如何解决这个问题,采用了文件重命名的方案去替代解决。

上传文件重命名

修改ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php

找到以下代码

if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}

在这段代码之后添加

$sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
$sFileName=date('YmdHis').'.'.$sExtension;

 

From: http://witmax.cn/ckfinder-rename-file.html






免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM