A commonly used tool, php+CKFinder is a solution to the problem of garbled characters when uploading files with Chinese file names. This problem is mainly a solution to the problem of garbled characters when uploading images with Chinese file names.
Problem with garbled characters when uploading files with Chinese names
Find the following configuration code in 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'; |
Change UTF-8 to GB2312. After uploading, the file name is correct, but the link displayed in CKEditor is garbled because the character set used by the page where CKEditor is located is UTF-8. I have not studied how to solve this problem in detail. An alternative solution is to find a file renaming solution.
Upload file rename
Modify ckfindercoreconnectorphpphp5CommandHandlerFileUpload.php
Find the following code
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onClick="doCopy('copy3782')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3782><pre class="code">if ($sFileName != $sUnsafeFileName) { $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED; }
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onClick="doCopy('copy3357')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3357><pre class="brush: php; title: ; notranslate" title="">$sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName); $sFileName=date('YmdHis').'.'.$sExtension;