How to Fix ‘Sorry, This File Type Is Not Permitted For Security Reasons’ For a Website’s Server

Every hosting server supports certain file types that can be uploaded to it. When you get the ‘Sorry, This File Type Is Not Permitted For Security Reasons’ error; it means you're trying to upload an unsupported file type.

I understand how scary it can be. But there's nothing to worry about. The reason behind displaying such an error is to save files and folders from any malicious file type.

Sometimes, attackers use different file types that include a malicious script or something similar to hack a site.

Two Methods to Fix The Sorry, This File Type Is Not Permitted For Security Reasons Error

There are basically three methods, but you can make changes only in two. So, I am going to show you the solution.

Method 1). Edit the wp-config.php file

Before you make any changes, I suggest you revert changes after uploading a file you want to upload.

Here are a few steps to follow:

1). Open your hosting account's cPanel and look for the file manager.

How to Fix ‘Sorry, This File Type Is Not Permitted For Security Reasons’ For a Website’s Server

2). From the left-sidebar, click on public_html and scroll down to find the wp-config.php file. Don't get confused with folders. Files are visible at the bottom of them.

How to Fix ‘Sorry, This File Type Is Not Permitted For Security Reasons’ For a Website’s Server

3). Right-click and select "Edit".

4). Click on "Edit" from the popup that shows up.

How to Fix ‘Sorry, This File Type Is Not Permitted For Security Reasons’ For a Website’s Server

5). You will see a new tab with codes of the wp-config.php file. Here is the code you have to add:

define('ALLOW_UNFILTERED_UPLOADS', true);

Note: Add this line above ‘That’s all, stop editing! Happy publishing.’

From the top-right corner, don't forget to click on save changes.

Method 2). Edit the functions.php File

The functions.php file controls all the functions of a WordPress website. You can edit existing functions and add a new function.

Here, I am going to generate a custom function for you that will allow the upload of unsupported files.

Here are a few steps to follow:

1). Since you're already in the public_html directory, open the WP-CONTENT folder that has all the themes, plugins, and media files.

2). Click on the theme folder that you're currently using. You might have multiple themes installed, but you have to edit the file of an active theme.

3). Scroll down to find the functions.php file and right-click to edit.

4). On a new tab, here is the required code you can add:

function my_custom_mime_types( $mimes ) {
   // Add new MIME types here
   $mimes['abiword'] = 'application/x-abiword';
   return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );

 

Please don't forget to save changes.

The third method is to contact your hosting customer support. Sometimes, a hosting company doesn't let you add such codes to edit wp-config.php or functions.php.

In such a situation, only your web hosting customer support representative can help you. Nowadays, most companies offer live chat and email tickets.

Conclusion

You should be careful when editing files to allow the upload of unsupported file types. Whether you use wp-config.php or functions.php, remove the code just after uploading a file.

I am sure; you wouldn't want to take any risk and compromise with your site's security. Isn't it easy to fix the "Sorry, This File Type Is Not Permitted For Security Reasons" error?

Was this article helpful?