打开wp-admin/includes/file.php文件
找到wp_handle_upload这个函数,按照下面的代码进行修改.主要修改两行
function wp_handle_upload( &$file, $overrides = false, $time = null ) { //部分代码略去 // Move the file to the uploads dir //$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 ), 'upload' ); //将上行代码修改为下面的代码,修正中文文件名编码问题 return apply_filters( 'wp_handle_upload', array( 'file' => $uploads['path'] . "/$filename", 'url' => $url, 'type' => $type ) , 'upload'); }
近期评论