A-A+

wordpress上传中文附件出现乱码和后台上传中文图片不显示解决方法

2015年12月22日 WordPress 暂无评论 阅读 4,414 views 次

今天用wordpress搭建公司企业网站,发现上传的图片不能正常显示。检查图片链接,完全正确,为什么不显示呢?于是登录ftp查看,才发现上传的图片中包含中文,而这些中文乱码了,导致访问不了。下面给出解决办法:

 

编辑wp-admin/includes/file.php这个文件

1、查找:

$new_file = $uploads['path'] . "/$filename";

替换为:

$new_file = $uploads['path'] . "/" . iconv("UTF-8","GB2312",$filename);

注意,之需要替换第一处即可!

 

2、查找

return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' );

修改为:(修正中文文件名编码问题)

return apply_filters( 'wp_handle_upload', array( 'file' => $uploads['path'] . "/$filename", 'url' => $url, 'type' => $type ) , 'upload');

标签:

给我留言