Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload .exe file in WordPress website

Tags:

wordpress

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

like image 488
User27 Avatar asked Dec 23 '22 22:12

User27


2 Answers

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');
like image 113
User27 Avatar answered Dec 28 '22 23:12

User27


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);
like image 28
JoWie Avatar answered Dec 29 '22 00:12

JoWie