Fix WordPress Issue “Sorry, this file type is not permitted for security reasons.”

Sometimes in WordPress site you try to upload file and got the error message “Sorry, this file type is not permitted for security reasons.” as shown in the following screenshots which results in not allowing you to upload that file.

Sorry, this file type is not permitted for security reasons.
Sorry, this file type is not permitted for security reasons.
Sorry, this file type is not permitted for security reasons.
Sorry, this file type is not permitted for security reasons.

This happens because by default WordPress allows users to upload only any of the following file types and if you try to upload any other file types then you get the error message “Sorry, this file type is not permitted for security reasons.”.

Images :
.jpg
.jpeg
.png
.gif

Documents :
.pdf (Portable Document Format; Adobe Acrobat)
.doc, .docx (Microsoft Word Document)
.ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
.odt (OpenDocument Text Document)
.xls, .xlsx (Microsoft Excel Document)

Audio :
.mp3
.m4a
.ogg
.wav
.midi
.mid
.wma
.mp4
.m4v
.flv

Video :
.mp4, .m4v (MPEG-4)
.mov (QuickTime)
.wmv (Windows Media Video)
.avi
.mpg
.ogv (Ogg)
.3gp (3GPP)
.3g2 (3GPP2)
.webm
.ogv

Others :
.zip
.key

To allow file types to upload other than listed above, you can fix this issue using any of the following various ways.

Fix the Issue Using WordPress Multisite Settings

If you are using WordPress Multisite then you can add the file type that you want to upload in the “Upload file types” option of WordPress Multisite Upload Settings in network admin area on the following path as shown in the below screenshot.

Network Admin Area -> Settings -> Upload Settings

Multitisite Upload file types
Multitisite Upload file types

Fix the Issue Using WordPress Plugins

You can use any of the following plugins on your site and configure it to allow to upload file types on your site.

WP Add Mime Types

Mime Types Extended

Unsafe Mimetypes

Mime Types Plus

Fix the Issue to Allow to Upload All File Types in File Upload

You can set the WordPress constant ALLOW_UNFILTERED_UPLOADS to true that will allow you to upload all file types on your WordPress site.

To set ALLOW_UNFILTERED_UPLOADS constant to true just add the following line of code in the wp-config.php file of your WordPress install which you will find in the root directory of your WordPress setup.

define('ALLOW_UNFILTERED_UPLOADS', true);

You can add the above line of code in the wp-config.php file just above the following statement.

/* That's all, stop editing! Happy blogging. */

If you don’t want to edit the file wp-config.php then just download this Free WP TP Plugin and install it on your site. This plugin contains the following code.

<?php 
/*
Plugin Name: Free WP TP Plugin
Description: Quick Custom Solution Plugin for Implementing Custom Solution.
Version: 1.0.0
Author: Movin
Author URI: http://freewptp.com/
License: GNU General Public License (Version 2 - GPLv2)
*/


define('ALLOW_UNFILTERED_UPLOADS', true);

Fix the Issue to Allow to Upload Specific File Type in File Upload

If you want to allow specific file types to upload and not all file types as above or want to forbid specific file types then you can use the following code in the functions.php file of your child theme or use the Free WP TP Plugin and replace the code in its file freewptp-plugin.php on line 12 with the below code.

function free_wp_tp_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['gz']  = 'application/x-gzip';
 
   // If you want to forbid specific file types which are otherwise allowed,
   // specify them here.  You can add as many as possible.
   unset( $mime_types['bin'] );
 
   return $mime_types;
}
 
add_filter('upload_mimes', 'free_wp_tp_enable_extended_upload');

Please change the above code with correct file types according to your need.

Fix the Issue by Contacting Web Host

If your issue doesn’t fix using any of the above solutions then this can be your web host issue as many hosts don’t support various types of files to upload on server due to security issue so you can contact your web host to resolve it.

I hope you find this free tutorial helpful but if you have any questions regarding fixing this issue or any other WordPress question then feel free to ask it in our free WordPress support forum where i would like to answer you.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *