How to Fix “Sorry, This File Type Is Not Permitted for Security Reasons” Error in WordPress
Can anyone help me with this problem?
The “Sorry, this file type is not permitted for security reasons” error in WordPress occurs when you try to upload a file with an extension that WordPress does not allow by default. This security measure is in place to protect your website from potentially harmful file types that could contain malicious code. However, if you need to upload a file type that WordPress is blocking for legitimate reasons, you can follow these steps to fix the issue:
Method 1: Use a Plugin (Recommended for Non-Technical Users)
- Log in to your WordPress dashboard.
- Go to the “Plugins” section and click “Add New.”
- In the search bar, type “File Type Mime Types” or a similar search term.
- Find a plugin that allows you to manage allowed file types, such as “File Type Mime Types” or “MIME Types Plus.”
- Install and activate the plugin.
- Once activated, go to the plugin’s settings, usually located under “Settings” or “Media.”
- You should see a list of file types with checkboxes. Enable the checkbox next to the file type you want to allow.
- Save your changes.
- Try uploading the file again to see if the error is resolved.
Method 2: Modify the WordPress Functions File (For Advanced Users)
If you are comfortable with editing your theme’s functions.php file, you can modify it to allow additional file types manually. Here’s how:
- Access your WordPress site’s files using an FTP client or a file manager in your hosting control panel.
- Navigate to the theme folder where your WordPress site’s active theme is located. This is usually in the
/wp-content/themes/
directory. - Locate the
functions.php
file within your active theme folder. - Download a backup copy of the
functions.php
file to your computer before making any changes. - Open the
functions.php
file in a code editor. - Add the following code snippet to the end of the file, just before the closing PHP tag (
?>
), if it’s not already there:
function custom_upload_mimes( $existing_mimes ) {
// Add new allowed file types here
$existing_mimes['file_extension'] = 'mime/type';
return $existing_mimes;
}
add_filter( 'upload_mimes', 'custom_upload_mimes' );
Replace 'file_extension'
with the file extension you want to allow (e.g., ‘pdf’, ‘svg’, ‘docx’) and 'mime/type'
with the correct MIME type for that file extension.
- Save the changes to the
functions.php
file and upload it back to your server. - Try uploading the file again to see if the error is resolved.
Remember that modifying your theme’s functions.php file should be done carefully, and it’s always a good idea to have a backup of the file in case something goes wrong. If you are not comfortable with code editing, using a plugin (Method 1) is a safer option.