最近打算学习安装配置WordPress,当然同时也在学习PHP+MySQL,希望以后能做一些关于WordPress定制和二次开发,包括主题和插件。在成功安装WordPress3.5中文版之后,就测试了一下。其他的功能之前也熟悉一点,但是今天上传了一个含有中文的docx文档上去,然后点开附件,发现报错。无法下载和查看开始上传的那个文件,因为中文名文件在上传之后出现了乱码。

解决办法如下:

找到/wp-admin/includes/file.php这个文件,并最如下修改:

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

修改完上传至服务器,问题就解决啦,其实很简

参考地址:http://www.okayseo.com/?p=1070

相关文章:

  • 2022-02-19
  • 2022-12-23
  • 2021-10-15
  • 2021-06-29
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
相关资源
相似解决方案