小鳥雲虛擬主機Wordpress上傳中文附件出現亂碼

shangyun發表於2021-10-27

總結了小鳥雲虛擬主機在使用過程中,Wordpress上傳中文附件出現亂碼和後臺上傳中文圖片不顯示解決方法

編輯wp-admin/includes/file.php這個檔案

1、查詢:
$new_file =  u p l o a d s [ ′ p a t h ′ ] . " / uploads['path'] . "/ u p l o a d s [ p a t h ] . " /filename";
替換為:

$new_file =  u p l o a d s [ ′ p a t h ′ ] . " / " . i c o n v ( " U T F − 8 " , " G B 2312 " , uploads['path'] . "/" . iconv("UTF-8","GB2312", u p l o a d s [ p a t h ] . " / " . i c o n v ( " U T F 8 " , " G B 2 3 1 2 " ,filename);
注意,之需要替換第一處即可!

2、查詢
return apply_filters( ‘wp_handle_upload’, array( ‘file’ => $new_file, ‘url’ => $url, ‘type’ => $type ), ‘upload’ );
修改為:(修正中文檔名編碼問題)

return apply_filters( ‘wp_handle_upload’, array( ‘file’ =>  u p l o a d s [ ′ p a t h ′ ] . " / uploads['path'] . "/ u p l o a d s [ p a t h ] . " /filename", ‘url’ => $url, ‘type’ => $type ) , ‘upload’);

可以去小鳥雲看看。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69990023/viewspace-2839665/,如需轉載,請註明出處,否則將追究法律責任。

相關文章