在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