How to Fix “Sorry you are not allowed to upload this file type” Error WordPress

The “Sorry, you are not allowed to upload this file type” error in WordPress often arises when you attempt to upload a file format that is not permitted by your website’s configuration. This can be due to security reasons performance considerations or specific site requirements

In this article, we will explore various methods to resolve WordPress upload file type error issue and allow you to successfully upload the desired file type.

Understanding the Error

Before getting into solutions it is important to understand why WordPress file upload issue error occurs:

file upload error
  1. Your WordPress website’s configuration might explicitly prohibit certain file types such as .exe .php or .phtml to prevent malicious code execution.
  2. WordPress has built-in security mechanisms to protect your site from potential vulnerabilities. These measures can sometimes restrict specific file types.
  3. Certain plugins or themes might introduce additional file type restrictions or compatibility issues.
  4. Your web server’s configuration may have limitations on the types of files it can process.

Troubleshooting Steps

The following are troubleshooting steps to fix WordPress file upload error:

WordPress function.php File

While the functions.php file primarily controls your theme’s functionality, you can also use it to modify certain WordPress settings including file upload restrictions. Navigate to the “Appearance” section in your WordPress dashboard. Click on the “Theme File Editor” option.

function php file

Add a custom allowed file types WordPress filter with the following code:

function my_allowed_file_types($mimes) {
    $mimes['pdf'] = 'application/pdf';
    $mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
    return $mimes;
}
add_filter('upload_mimes', 'my_allowed_file_types');

Click Update File at the bottom of the dashboard.

Using .htaccess file

If you have access to your website’s files via FTP or file manager which is in my case cPanel, navigate to the “public_html” directory of your WordPress installation. Look for the .htaccess file.

.htaccess

It may be hidden you need to check box the “Show Hidden Files” option from the “Settings” section.

hidden files

Once you have access to the .htaccess file you can add or modify WordPress file upload restrictions using specific directives. Here are some common examples:

Deny File Types

Edit the following lines in your .htaccess file:

<FilesMatch "\.(exe|php|phtml)$">
    Deny from all
</FilesMatch>

This code denies access to files with the .exe .php and .phtml extensions. You can modify the extensions to match your desired restrictions.

Allow File Types

Edit the following lines in your .htaccess file:

<FilesMatch "\.(jpg|jpeg|png|gif)$">
    Allow from all
</FilesMatch>

This code allows access to files with the .jpg .jpeg .png and .gif extensions. You can adjust the extensions to match the file types you want to permit.

Themes & Plugins Compatibility

Deactivate all plugins temporarily. Try saving your content again. If the error disappears a plugin is the issue. To identify the problematic plugins, reactivate them one by one and test them after each activation to pinpoint the conflicting ones. To perform deactivation navigate to the “Plugins” section in your WordPress dashboard. Deactivate all plugins from “Bulk Actions”.

deactivate plugins

Similar to plugins your theme might be causing the issue. Switch to a default WordPress theme like Twenty Twenty-Four. If the error disappears you have identified a theme-related problem. You can then try updating your theme to the latest version or explore alternative themes that are compatible. To do this, log into the WordPress dashboard and navigate to the “Appearance” section then the “Themes” option.

wordpress theme

Server Side Configuration

While WordPress provides options to control file type restrictions on the client side, server-side configuration can also play a significant role. For Apache configuration modify the httpd.conf file to add or modify MIME types for specific file extensions. This ensures the server correctly recognizes and handles the uploaded files.

AddType application/pdf pdf
AddType application/msword doc
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx

Similarly, for NGINX configuration edit the nginx.conf file to define MIME types for different file extensions.

types {
    types {
        pdf application/pdf;
        doc application/msword;
        docx application/vnd.openxmlformats-officedocument.wordprocessingml.document;
    }
}

Using WordPress Plugin

If you frequently encounter the “Sorry, you are not allowed to upload this file type” error and need to support a wide range of file formats exploring plugins can be a valuable solution. These plugins often extend WordPress’s file-handling capabilities allowing you to upload and manage various file types. Here are some popular plugins that can help:

  • WP Extra File Types: Provides a comprehensive extra file type within your WordPress dashboard and also supports a vast array of file types including documents, images, audio, video, and more.
  • WP Media Folder: Organize your media library into folders and subfolders that support various file types and provide options for custom thumbnails and watermarks.

To install the WP Extra File Types plugin navigate to the WordPress “Plugin” section then click “Add New Plugin”, search for the respective plugin click “Install Now” then “Activate” the plugin.

WP extra file types

After activating the plugin navigate to the “Setting” section on WordPress. You can see the additional “Extra File Type” option. Click on it you can see the interface which allows you to integrate multiple file types:

multiple file types

Click the Save Changes button after selecting your preferred file type.

Important Notes

Following are some important notes while resolving the WordPress file upload error:

  • Keep your WordPress installation and plugins up-to-date to benefit from security patches and potential bug fixes that might affect file upload functionality.
  • Before making significant changes to your WordPress configuration create a complete backup of your website to secure your data.

Conclusion

By following these steps and considering the important notes you should be able to effectively resolve the “Sorry, you are not allowed to upload this file type” error in WordPress and successfully upload your desired files. Experiment with different approaches to find the best solution for your situation.

When it comes to buying hosting Ultahost is the best place to provide WordPress VPS hosting for bloggers, business owners, web designers, and developers. A customizable and scalable VPS is made just for you.

FAQ

What causes “Sorry, you are not allowed to upload this file type” error in WordPress?
How can I fix the file type upload error in WordPress?
Can I upload any file type in WordPress?
Is it safe to allow all file types in WordPress?
What plugin can help fix this upload error?
Can I fix this error without a plugin?
Does updating WordPress affect file type permissions?

Related Post

How To Fix the ERR_NETWORK_CHANGED Error in C

The internet is an essential component of our online ex...

How to Fix the HTTP Image Upload Error in Wor

Have you ever received the avoided HTTP image upload er...

How to Set Password Protected WordPress Page

In many cases, you might want to restrict access to cer...

How to Fix WordPress 429 Too Many Requests Er

In the world of website management, you might face the ...

How to Change the WordPress URL

The URL stands for Uniform Resource Locator is serves ...

How to Display Related Posts in WordPress

Engaging your readers and keeping them on your WordPres...

Leave a Comment