wordpress 支持上传中文名称文件

添加文章难免要传个图、文件啥的,可是呢,上传中文名称的文件竟然不行,找了半天,中文乱码,脑残了,竟然忘了这个事,哎

修改其实很简单,只需要两步

1、/wp-admin/includes/file.php

 

function _wp_handle_upload( &$file, $overrides, $time, $action ) {

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

//

/*return apply_filters( 'wp_handle_upload', array(
        'file' => $new_file,
        'url'  => $url,
        'type' => $type
    ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' );*/
// 修正为

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

 

 

 

 

 

保存后台刷新就可以了。。。

 

posted @ 2018-02-07 17:54  西贝小小凤  阅读(1187)  评论(0编辑  收藏  举报