wordpress 上传附件中文文件名乱码解决办法
打开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');
}
查看完整版本: wordpress 上传附件中文文件名乱码解决办法
Tags: 乱码