【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