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



Encountering the “Sorry, you are not allowed to upload this file type” error message when trying to upload media files in WordPress can be frustrating, but it’s usually a solvable issue. This error occurs because WordPress has security measures in place to prevent potentially harmful file types from being uploaded to your website. Here’s how you can troubleshoot and fix this issue:

  1. Check File Type and Extension: Make sure the file you’re trying to upload has a common and valid file extension. WordPress generally allows file types like images (jpg, png, gif), audio (mp3, wav), video (mp4, mov), and documents (pdf, docx). Double-check that your file has one of these supported extensions.
  2. File Naming: Sometimes, an unusual or incorrectly formatted file name can trigger the error. Try renaming the file to something simple and without special characters or spaces.
  3. Plugin Conflicts: If you have any security or media-related plugins installed, they might be interfering with the file upload process. Temporarily deactivate plugins related to security or media handling and try uploading the file again. If the error goes away, reactivate the plugins one by one to identify the culprit.
  4. Theme-related Issues: Your theme could also be affecting the media upload process. To test this, temporarily switch to a default WordPress theme (like Twenty Twenty-One) and try uploading the file again. If it works with the default theme, your original theme might have compatibility issues.
  5. Check MIME Types: WordPress uses MIME types to identify file types. If your server’s MIME type settings are incorrect, you might face this error. You can use a plugin like “MIME Types Extended” to manage MIME types or add code to your theme’s functions.php file to allow specific file types. However, be cautious when editing code, as it can impact your website’s functionality.Here’s an example of code to add in functions.php to allow additional file types:
    php
    function custom_myme_types($mime_types){
    $mime_types['extension/type'] = 'mime/type';
    // Add more mime types as needed
    return $mime_types;
    }
    add_filter('upload_mimes', 'custom_myme_types', 10, 1);



    Real life example –

    function my_custom_mime_types( $mimes ) {
    // New allowed mime types.
    $mimes['svg'] = 'image/svg+xml';
    $mimes['svgz'] = 'image/svg+xml';
    $mimes['doc'] = 'application/msword';
    // Optional. Remove a mime type.
    unset( $mimes['exe'] );
    return $mimes;
    }
    add_filter( 'upload_mimes', 'my_custom_mime_types' );

     



  6. File Size Limitations: Sometimes, the server or your WordPress settings might have a limit on the maximum file size you can upload. Ensure that your file is within the allowable size limit.
  7. Server Configuration: In some cases, server configurations can prevent certain file types from being uploaded. Contact your web hosting support to inquire about any server-side restrictions.
  8. .htaccess File: If your server uses Apache, there might be rules in the .htaccess file that restrict certain file types. Make sure there are no rules specifically blocking the file types you’re trying to upload.





Remember to back up your site before making any significant changes to themes, plugins, or code. If you’re not comfortable troubleshooting these issues yourself, it’s a good idea to seek help from a knowledgeable developer or your hosting provider’s support team.

Edit the wp-config.php  to fix “Sorry, you are not allowed to upload this file type ” in WordPress Temporariliy since keeping the following on in wp-config file would be a security risk.  

define('ALLOW_UNFILTERED_UPLOADS', true);

Related Posts

 

Leave a Reply