上传 rar 文件时出现错误,解决方法
在 functions.php 文件中添加如下函数
function my_custom_mime_types( $mimes ) {
// 添加新类型
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
$mimes['doc'] = 'application/msword';
$mimes['jfif'] = "image/jfif";
// 可项,删除已有类型
unset( $mimes['exe'] );
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );
参考:https://developer.wordpress.org/reference/hooks/upload_mimes/
<span style="color: #ff0000;">注意:此方法只针对部分,RAR 文件类型仍不可行</span>