I need to upload .exe file in my wordpress website. I have already added define('ALLOW_UNFILTERED_UPLOADS', true); in my wp-config.php file but still showing the same error. Please help. Thanks
Thanks for you comment, below code solved my issue,
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');
I encountered the same issue and the current answer no longer works for me.
The following works for me in wordpress 5.7.2 (tested using the basic file uploader):
Create a new .php
file in the wp-content/mu-plugins
directory, with the following content:
<?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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With