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' );

 

 

 

 

 

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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM