How to Fix "Sorry, this file type is not allowed for security reasons" Error in WordPress

Have you guys been uploading files to WordPress Media Libraryluckily "Sorry, this file type is not allowed for security reasons." The error message?

Or, does it see "{filename} Upload failed." The error message?

This error is due to WordPress Only Allows Uploading Specific File Types, files that are not on the supported list will be automatically blocked. However, it is possible to adjust WordPress settings to allow uploading of files in other formats.

In the article, there will be a few simple ways to help you guys out "Sorry, this file type is not allowed for security reasons." This error uploads the required files without any problem.

Image [1] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

Causes of "Sorry, this file type is not allowed for security reasons" error

WordPress restricts uploaded file types by default to prevent security risks posed by executable or unknown files. If you try to upload an unsupported file type, you will see the following error message:

"Sorry, this file type is not allowed for security reasons."

Or, in the latest version of WordPress, you may see it:

"Sorry, you are not allowed to upload this file type."

Image [2] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

File Types Supported by WordPress by Default

formSupported file extensions
photograph.jpg, .jpeg, .png, .gif, .ico, .bmp, .svg, .tiff
(computer) file.pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx, .odt, .xls, .xlsx, .csv, .psd, .rtf
sound frequency.mp3, .m4a, .ogg, .wav, .flac, .aac
video.mp4, .m4v, .mov, .wmv, .avi, .mpg, .ogv, .3gp, .3g2, .webm

Typically, unsupported file formats (such as .tff maybe .woff(i.e. custom font files) will trigger this error.

This can be done by modifying the MIME Type to solve this problem. Another way is to use the FTP maybe File manager provided by WordPress hosting to upload files. However, these methods are less convenient compared to the media library that comes with WordPress.

How to fix "Sorry, this file type is not allowed for security reasons" error? (7 easy ways)

When encountering this error, I usually start with the wp-config.php A small piece of code is added to the file. This is not complicated if you are familiar with file editing. However, if you don't want to modify the code, you can also use the WordPress Pluginto resolve.

In addition, it is important to scrutinize Is the file extension spelled correctly. If you want to upload SVG filesIt can be done with WPCode Such a plugin, which allows you to easily add the necessary code without having to manually modify the file.

Before making any changes, it is recommended that in advanceBackup SitesThe

Having shared my go-to solution, let's take a closer look at what can be done to fix this issue on your own. Also, learn how to fix 500 Internal server error maybe 404 Error Solution on WordPress.

1. In wp-config.php Add the code snippet to the file

To allow all file types to be uploaded to the site, you need to add a new file type to the wp-config.php file to add a line of code. This file stores important information about the site's database, so be careful when modifying it.

modifications wp-config.php file

  • pass (a bill or inspection etc) SSH Connect to the server and find the public_html directory (or the root directory of the website) in the wp-config.php Documentation.
  • show (a ticket) wp-config.phpin "/ That's all, stop editing. Happy blogging. /" This line of code for the above Add the following code:
define('ALLOW_UNFILTERED_UPLOADS', true);
  • Save the file and upload it back to the server like this Remove file type restrictions, allowing all files to be uploaded.
Image [3] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

Attention: only in Determining the security of uploaded files Use this method when otherwise it may be a safety hazard.

modifications .htaccess Allow all files to be uploaded (for Apache servers)

If the server uses the Apachecan be modified .htaccess fileto allow all file types to be uploaded.

Steps:

  • pass (a bill or inspection etc) FTP/SFTP Access to the server (e.g., using FileZilla).
  • go into public_html catalogsThe
  • locate .htaccess file (if you can't see it, make sure it's enabled) Show hidden files).
  • downloading .htaccess file locally and open it with a text editor.
  • Add the following code to the file to allow all file types to be uploaded
AddType application/octet-stream . *

</IfModule
  • If you only want to allow specific file types (such as JPG, PNG, PDF, SVG), could read:
AddType application/octet-stream .jpg .png .pdf .svg

</IfModule
  • Save file and re-uploaded to public_html directory, replacing the original .htaccess Documentation.

This allows the Apache server to upload files of the specified type.

Image [4] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

2. Use WordPress plugin

If you don't want to modify the wp-config.php file, you can use the WordPress plugin to change the type of file that is restricted from being uploaded.

Attention: Third-party plugins can sometimes interfere with the normal functioning of your website, so be careful when using them.

With the WP Extra File Types plugin

WP Extra File Types is a free plugin available in the WordPress plugin repository. Here is how to use it:

Install and activate the plugin

  • Go to the WordPress backend
  • leave for Plugins > Install PluginsSearch WP Extra File Types
Image [5] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
  • strike (on the keyboard) mounting furthermore activate

Enabling additional file types

  • After activating the plugin, go to Settings > Extra File Types
Image [6] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
  • You will see a list of file types, check the ones you want to enable.
  • Click "Save Changes" Application Settings
Image [7] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

Add custom file types (optional)

  • At the bottom of the settings page, you can manually add custom file types
Image [8] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
  • Enter the file extension and MIME type, then save it

    Allow additional file types in WordPress multisite mode

    If you use the WordPress Multisite(Multisite)The uploaded file types can be adjusted without plug-ins or code:

    • Go to the WordPress Admin Backend
    • Navigate to "Settings" > "Network Settings".
    Image [9] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
    • Scroll to the "Upload Settings" sectionin "Allowed file types" Add the desired file extensions in the input box (separated by spaces)
    Image [10] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
    • Click "Save Changes"

      This way, file upload settings can be adjusted directly in the WordPress backend without plugin or code modifications.

      3. Checking the spelling of file extensions

      Sometimes, even if you have successfully uploaded similar files before, you may encounter "File type not allowed." of the error. One of the most common causes of Misspelled file extensionsThe

      What is a file extension?

      The file extension is the name of the file at the end of the short suffix(usually 3 to 4 letters) that identifies the file type. Example:

      • .jpg,.jpeg(Photos)
      • .pdf(Documentation)
      • .doc,.docx(Word document)
      • .ppt,.pptx(PPT file)

      WordPress relies on extensions to determine file types, so the Even a small spelling mistake It may also cause the upload to fail.

      How to view file extensions?

      Windows computers:

      • Open the folder containing the file.
      • strike (on the keyboard) "View." Tabs > "Show"The
      • tick "File extension"The
      Image [11] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
      • Now the extensions of all the files can be seen.

        Mac computers:

        1. show (a ticket) Finderand then click on the "Finder" > "Settings" (or "Preferences")The
        2. go into "Advanced" Tab.
        3. Make sure to check the "Show all file extensions"The
        Image [12] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

        Make sure the extension is correct

        Check for spelling errors in file extensionsThe

        • For example, if the filename is document.doccxThis is the wrong extension.

        Right-click on the file and select "Rename".and then fix it to the correct extension, e.g. document.docxThe

        Save changes and re-upload the fileThe

          This avoids misspellings of extensions that could result in a WordPress Upload ErrorThe

          4. Increase file upload size limit

          WordPress has a preset limit on file upload size. If you try to upload Allowed file typesbut still encountered "Sorry, this file type is not allowed for security reasons." error, probably because the file Exceeded the allowed upload sizeThe

          rise Maximum file upload limit It can help to solve this problem. You can refer to the articleHow to Increase WordPress Maximum Upload File Size: The Complete GuideThe

          Here are a few ways to increase the upload size allowed by WordPress:

          modifications .htaccess Documentation (for Apache servers)

          If the WordPress site is running on Apache server On, you can modify the .htaccess file to increase the size limit of the uploaded file.

          Steps:

          • Connect to the server using FTPto the WordPress root directory (public_html).
          Image [13] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
          • locate .htaccess file(If you don't see it, make sure it's enabled) Show hidden files).
          • show (a ticket) .htaccess fileand in # BEGIN WordPress Add the following code before
            php_value upload_max_filesize 64M
            
            php_value post_max_size 128M
            
            php_value memory_limit 256M
            
            php_value max_execution_time 300
            
            php_value max_input_time 300
            • Save file and uploaded back to the server.

              This increases the maximum upload file size allowed by WordPress and adjusts the memory limit and script execution time to ensure that larger files can be uploaded without problems.

              modifications functions.php Files (for NGINX servers)

              NGINX server need not .htaccessThe following is an example of the changes that would need to be made to the thematic functions.php file to increase the upload limit.

              Steps:

              • Go to the WordPress backend.leave for::Appearance > Theme File Editor(Theme File Editor).
              • locate functions.php file And open.
              Image [14] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
              • Add the following code to the end of the file::
              @ini_set( 'upload_max_size' , '64M' );
              
              @ini_set( 'post_max_size', '128M' ).
              
              @ini_set( 'max_execution_time', '300' );
              • Save fileThe

                Attention: This modification Only for the current theme, if you change the theme, you need to add the code again.

                modifications php.ini Documentation (direct configuration of the server)

                If there is Direct Access Server PHP Configuration permission, you can modify the php.ini file to increase the file upload limit.

                Steps:

                • Connect to the server via FTP or SSHFind Web site root directory lower php.ini Documentation.
                Image [15] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
                • If not php.ini file, you can create a new one.
                • Add the following code::
                upload_max_filesize = 64M
                
                post_max_size = 128M
                
                memory_limit = 256M
                • Save the file and upload it back to the serverThe

                  This allows the site to support larger file uploads.

                  5. Enable SVG support with plug-ins

                  If you are uploading the SVG files run into "Sorry, you are not allowed to upload this file type." The error is due to the fact that WordPress does not allow uploading SVG files by default., mainly for security reasons.

                  However, it is possible to plug-in (software) Securely enable SVG support.

                  Method 1: Use Safe SVG plug-in

                  • Go to the WordPress backendNavigate to Plugins > Install PluginsThe
                  • look for sth. "Safe SVG" plugin.Installation and activationThe
                  Image [16] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
                  • Once activated, you can upload SVG files freely!The program will not be limited by WordPress anymore.

                    Method 2: Enable SVG Uploading with WPCode Plugin

                    Image [17] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                    Go to the WordPress backendGo to Code Snippets > Add Code SnippetThe

                    Image [18] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                    Search for "SVG"Find "Allow SVG files to be uploaded"(Allow SVG Files Upload) code snippet.

                    Click on "Use code snippets".(Use Snippet).

                    Image [19] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                    On the next page, enable the code snippet and click "Update".(Update).

                    Image [20] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                      expense or outlay Safe SVG maybe WPCode Both of these methods, which can be Upload SVG files securelyTo avoid WordPress blocking this file type.

                      6. Modifications .htaccess MIME type in the file

                      Another way to allow WordPress to upload more file types is the modifications .htaccess MIME type in the fileThis will force WordPress to recognize and allow specific file extensions.

                      procedure

                      • expense or outlay FTP client(e.g. FileZilla) or cPanel File Manager Go to the WordPress root directory and find the .htaccess Documentation.
                      Image [21] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
                      • If the file is hiddenIn the settings, enable the Show hidden files Options.
                      Image [22] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error
                      • Open with a text editor .htaccess file, add the following code at the end of the file:
                      AddType image/svg+xml .svg
                      
                      AddType application/octet-stream .zip
                      
                      AddType application/pdf .pdf
                      
                      AddType application/msword .doc

                        This code allows to upload SVG, ZIP, PDF and DOC filesThe file type can be modified according to the requirements.

                        7. Update WordPress and plugins

                        WordPress regularly improves security measures, including file upload rules. If you're using an older version, certain file types may be unnecessarily Limitations.

                        In addition, some plugins (especially Security Plug-ins maybe Media Management Plugin) may strengthen the upload rules, and the new version may tweak those restrictions.

                        How do I update WordPress, themes and plugins?

                        Update WordPress Core

                        • go into WordPress Backend > Dashboard > UpdatesThe
                        • Check for the presence of new versionIf so, click "Update Now" Perform the installation.
                        Image [23] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                          Updated themes and plugins

                          • Updated Themes: Enter Appearance > ThemesInspection Currently used themes Is there an update, click Update.
                          • Updating Plug-ins: Enter Plugins > Installed PluginsCheck to see if there is a Available UpdatesIn particular, the Security Plug-ins, and then click Update.
                          Image [24] - How to Fix WordPress "Sorry, this file type is not allowed for security reasons" Error

                            Update with WP-CLI command line (for SSH access)

                            If there is SSH accessYou can quickly update WordPress components with the WP-CLI command.

                            Update all plug-ins

                            wp plugin update --all

                            Update all themes

                            wp theme update --all

                            reach a verdict

                            Hopefully this article will help you guys out "Sorry, this file type is not allowed for security reasons." The error.

                            Whether it's a modification of the wp-config.php file, used a plugin, checked the file extension, or tried something else, all of these solutions should help you fix the File type upload errorThe

                            Attention: Before making any changesBe sure to back up your websiteto avoid accidents.


                            Contact Us
                            Can't read the article? Contact us for free answers! Free help for personal, small business sites!
                            Tel: 020-2206-9892
                            QQ咨询:1025174874
                            (iii) E-mail: info@361sale.com
                            Working hours: Monday to Friday, 9:30-18:30, holidays off
                            © Reprint statement
                            This article was written by Banner1
                            THE END
                            If you like it, support it.
                            kudos94 share (joys, benefits, privileges etc) with others
                            commentaries sofa-buying

                            Please log in to post a comment

                              No comments