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