在WordPress 4.7.1中a change was introduced 检查上传文件的真正mime类型。这打破了SVG或DOCX等文件类型的上传。WordPress Core中已经存在此问题的票证,您可以在其中阅读更多信息:
某些非图像文件在4.7.1之后无法上载(https://core.trac.wordpress.org/ticket/39550)https://core.trac.wordpress.org/ticket/39552)Atemporary 建议的解决方法(在解决此问题之前)是以下插件:
Disable Real MIME Check
如果您不想使用该插件,以下是相同的功能:
add_filter( \'wp_check_filetype_and_ext\', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( \'4.7.2\' !== $wp_version ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
\'ext\' => $filetype[\'ext\'],
\'type\' => $filetype[\'type\'],
\'proper_filename\' => $data[\'proper_filename\']
];
}, 10, 4 );
请注意,这个被剪断的版本包含了一个版本检查,以便在WordPress更新后立即禁用修复。
Edit
该问题最初设置为在4.7.2中修复。但是自从
4.7.2 was an urgent security release, 修复程序没有进入该版本。现在应该在4.7.3中修复。