When you’re trying to add a file to your WordPress media library, you might come across an error saying, “Sorry, this file type is not permitted for security reasons.” This usually happens when the type of file you’re trying to upload doesn’t work well with WordPress.
But don’t worry! There are solutions to get around this issue and upload file types that aren’t directly supported. You can do this by adjusting your WordPress settings or by using a special tool called a plugin.
In this article, we’ll guide you through the different methods. These methods will help you fix the “Sorry, this file type is not permitted for security reasons” error, all while making sure your WordPress site remains safe and secure.
Why Does the “Sorry, This File Type Is Not Permitted for Security Reasons” Error Occur?
When dealing with the WordPress media library, you might come across a situation where you encounter the message “Sorry, this file type is not permitted for security reasons.” This usually happens when the format of the file you’re trying to upload isn’t compatible with WordPress.
By default, WordPress is set up to support specific types of files, such as images, documents, audio, and video. These include common extensions like .jpeg, .pdf, .mp3, and .mp4. Anything outside this predefined list triggers the “Sorry, this file type is not permitted for security reasons” error.
Why Does the “Sorry, This File Type Is Not Permitted for Security Reasons” Error Occur?
- Images: .jpeg, .jpg, .png, .gif, .ico
- Documents: .pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx, .odt, .xls, .xlsx, .psd
- Audio: .mp3, .m4a, .ogg, .wav
- Video: .mp4, .m4v, .mov, .wmv, .avi, .mpg, .ogv, .3gp, .3g2
For example, file types like .svg or .tiff for images, and .woff for custom fonts, are not supported by WordPress. This limitation is in place to prevent potentially harmful files from being uploaded accidentally, thus bolstering your website’s defenses against cyber threats.
It’s worth noting that depending on your version of WordPress, you might see a slightly different error message, such as “Sorry, you are not allowed to upload this file type.”
Fixing the “Sorry, This File Type Is Not Permitted for Security Reasons” Error
To resolve the “Sorry, This File Type Is Not Permitted for Security Reasons” error, there are various approaches you can take. Let’s explore the different methods:
Check File Extension Spelling
Sometimes, even supported file types trigger the error due to misspelled or changed file extensions. Before trying anything else, double-check that your file extensions are accurate.
Adjust WordPress Multisite Settings
If you’re using WordPress Multisite, you can modify the settings to allow additional file types. This is done through the Network Settings in the dashboard.
Edit wp-config.php File
By editing the wp-config.php file, you can enable the upload of various file types, even those not initially supported. Be cautious, as this involves modifying a system file and could potentially affect security.
To implement this method, you’ll need to access the WordPress installation directory via an FTP client or File Manager. Here’s how you can do it using Hostinger’s hPanel:
- Go to cPanel → File Manager.
- Open the public_html folder and access the wp-config.php file.
- Paste the following code snippet above the line
That’s all, stop editing! Happy publishing:
:
define('ALLOW_UNFILTERED_UPLOADS', true);
- Save the changes.
Keep in mind that enabling this option can expose your site to security risks. It’s recommended to revert the changes once you’ve uploaded the prohibited file type.
- Edit the Theme’s functions.php File: If directly modifying the wp-config.php file seems risky, you can add the upload mimes filter to your theme’s functions.php file. This method lets you upload specific file types individually.To implement this method:
- Head to Files → File Manager.
- Navigate to public_html → wp-content → themes, access your current theme’s folder, and then open the functions.php file.
- Paste the following syntax to the file. Replace
[‘gpx’] = ‘text/gpsxml’
with your preferred Multipurpose Internet Mail Extensions or MIME types:
function my_custom_mime_types( $mimes ) {
// Add new MIME types here
$mimes['gpx'] = 'text/gpsxml';
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );
Note that different operating systems might use varying versions of a similar file type, making their MIME values equally different. For example, .gpx files on Windows show as .gpsxml on macOS. So, instead of $mimes['gpx'] = 'text/gpsxml';
, add $mimes['gpx'] = 'application/gpsxml';
on macOS.
Use a WordPress Plugin
Numerous plugins, such as “WP Add Mime Types” exist to expand the range of allowed file types. These plugins can help you bypass the error and upload unsupported formats.
To use a plugin like “WP Add Mime Types“:
-
- From the WordPress admin area, install the plugin and activate it.
- Navigate to Settings → Mime Type Settings.
- In the Add Values section, enter the MIME type value for your desired file. For example, uploading a .woff file requires users to enter
woff = application/x-font-woff
. To add multiple MIME file types, separate each value by pressing Enter. - Click on the Save button.
Once you’ve tried these methods, you should be able to resolve the issue and upload your desired files without encountering the “Sorry, this file type is not permitted for security reasons” message.
Leave a Reply