Home > Backend Development > PHP Tutorial > Solution to garbled image file name uploaded by php ckeditor_PHP tutorial

Solution to garbled image file name uploaded by php ckeditor_PHP tutorial

WBOY
Release: 2016-07-13 10:49:02
Original
890 people have browsed it

Garbled file names are generally caused by Chinese characters, because ckeditor uses uft8 encoding. If our page uses gbk or gb2312, garbled characters may occur. The solution is just to rename the uploaded file.

Open commands.php in the editor/filemanager/connectors/php directory, find the FileUpload function, in

after
The code is as follows
 代码如下 复制代码

$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;

后添加

$sFileName = rand(0,100).".".$sExtension;

Copy code

$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;

Add
$sFileName = rand(0,100).".".$sExtension;

The rand function here can change the renaming rules as needed. Another solution to garbled image file names when uploading is to use the iconv function to convert the file name, but there is still a problem of duplicate names, so it is best to rename the image file name uploaded to Fckeditor http://www.bkjia.com/PHPjc/632759.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/632759.htmlTechArticleGarbled file names are generally caused by Chinese, because ckeditor uses uft8 encoding. If our page uses gbk or gb2312 may have garbled code problems. The solution is to upload files...
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