【CKFinder】解决上传中文名文件乱码和文件重命名的问题
生活随笔
收集整理的這篇文章主要介紹了
【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
轉載于:https://www.cnblogs.com/imluxin/archive/2012/03/14/2395289.html
總結
以上是生活随笔為你收集整理的【CKFinder】解决上传中文名文件乱码和文件重命名的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysqldump 常用备份选项,只备份
- 下一篇: 只要存心谦卑,各人看别人比自己强。