我需要在我的WordPress网站上上传.exe文件。我已经在wp-config.php文件中添加了define('ALLOW_UNFILTERED_UPLOADS', true);,但仍然显示相同的错误。请帮忙解决。 谢谢
我需要在我的WordPress网站上上传.exe文件。我已经在wp-config.php文件中添加了define('ALLOW_UNFILTERED_UPLOADS', true);,但仍然显示相同的错误。请帮忙解决。 谢谢
function enable_extended_upload ( $mime_types =array() ) {
// The MIME types listed here will be allowed in the media library.
// You can add as many MIME types as you want.
$mime_types['exe'] = 'application/exe';
return $mime_types;
}
add_filter('upload_mimes', 'enable_extended_upload');
我遇到了相同的问题,当前答案 对我已经不再适用。
以下内容在wordpress 5.7.2中适用(使用基本文件上传器进行测试):
在wp-content/mu-plugins
目录中创建一个新的.php
文件,并将以下内容添加到其中:
<?php
// specify a high priority so that the filter will run later
// there is a built in filter which will remove the entry for 'exe'
add_filter('upload_mimes', function($mimes) {
// this mimetype has to match exactly what
// finfo_file() will return, see wp_check_filetype_and_ext()
$mimes['exe'] = 'application/x-dosexec';
return $mimes;
}, 10000);