Home > Backend Development > PHP Tutorial > Solution to the problem of garbled Chinese name files uploaded by php+CKFinder_PHP Tutorial

Solution to the problem of garbled Chinese name files uploaded by php+CKFinder_PHP Tutorial

WBOY
Release: 2016-07-13 10:55:53
Original
1015 people have browsed it

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;
}
Copy after login
Add after this 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('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;
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632200.htmlTechArticleA commonly used tool, php+CKFinder solves the problem of garbled Chinese name files uploaded. This problem mainly involves uploading Chinese files. The solution to the problem that the file name of the image is garbled. Upload Chinese name...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template