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

Can anyone help me with this problem?

 

Asked on September 26, 2023 in Wordpress.
Add Comment
  • 1 Answer(s)

    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)

    1. Log in to your WordPress dashboard.
    2. Go to the “Plugins” section and click “Add New.”
    3. In the search bar, type “File Type Mime Types” or a similar search term.
    4. Find a plugin that allows you to manage allowed file types, such as “File Type Mime Types” or “MIME Types Plus.”
    5. Install and activate the plugin.
    6. Once activated, go to the plugin’s settings, usually located under “Settings” or “Media.”
    7. You should see a list of file types with checkboxes. Enable the checkbox next to the file type you want to allow.
    8. Save your changes.
    9. 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:

    1. Access your WordPress site’s files using an FTP client or a file manager in your hosting control panel.
    2. Navigate to the theme folder where your WordPress site’s active theme is located. This is usually in the /wp-content/themes/ directory.
    3. Locate the functions.php file within your active theme folder.
    4. Download a backup copy of the functions.php file to your computer before making any changes.
    5. Open the functions.php file in a code editor.
    6. 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.

    1. Save the changes to the functions.php file and upload it back to your server.
    2. 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.

    Answered on September 26, 2023.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.