Fix “Sorry, This File Type Is Not Permitted for Security Reasons” Error in WordPress

0
12
Non-Image File Upload Errors in WordPress

Fix “Sorry, This File Type Is Not Permitted for Security Reasons” Error in WordPress.

As the message implies, WordPress limits the types of files that you can upload to your site for security reasons.

The WordPress shows this error “Sorry, this file type is not permitted for security reasons” when you try to upload files to your website through admin dashboard. The users are only allowed to upload certain file types to WordPress websites for security reasons. This is to prevent users from uploading executable files to their websites.

There are a number of solutions to fix this security issue.

1. Add New Permitted File Types Using wp-config.php

WordPress includes an ALLOW_UNFILTERED_UPLOADS option that you can enable in your site’s wp-config.php file. Once enabled, you’ll be able to upload any file type to your WordPress Media Library.

Edit your site’s wp-config.php file is located in the root folder, You can edit that file via “File Manager” plugin or using your hosting Cpanel.

Then, while editing the wp-config.php file, add the following code snippet above the /* That’s all, stop editing! Happy blogging. */ line:

define('ALLOW_UNFILTERED_UPLOADS', true);

Make sure to save your changes.

2. Using a WordPress Plugin

Install and activate WP Add Mime Types.

  1. From your WordPress dashboard, navigate to Settings -> Mime Type Settings.
  2. In the Add Values section, add your desired MIME name and type.
  3. If the process is successful, the new MIME type should appear in the permitted list.

3. Editing the Theme’s functions.php File

  1. Access your WordPress installation directory (in most cases, it’s public_html) via an FTP client or File Manager.
  2. Navigate to wp-content -> themes, then access your current theme’s folder.
  3. Open the functions.php file and paste the following syntax in the file. Feel free to add your desired MIME types to the array. Don’t forget to save the changes.
  4. 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' );

You can also add multiple file types in one code snippet, like this:

1
2
3
4
5
6
function my_myme_types($mime_types){
    $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
    $mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
    return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments