Hey there, WordPress user! Are you scratching your head wondering why you can‘t upload that file to your Media Library? Seeing the "Sorry, this file type is not permitted for security reasons" message can certainly throw a wrench in your workflow.
But don‘t worry, I‘m here to help! As a WordPress expert, I‘ll walk you through exactly why this error pops up and multiple ways to securely fix it. By the end of this guide, you‘ll be confidently uploading those pesky file types in no time. Let‘s dive in!
Understanding WordPress File Upload Restrictions
First things first, let‘s talk about why WordPress limits the types of files you can upload out of the box. It all comes down to security.
WordPress is the most popular content management system in the world, powering over 40% of all websites. With that popularity comes the attention of hackers and bad actors looking to exploit any vulnerability they can find.
One common tactic is uploading malicious files disguised as innocent images, documents, or media. For example, a hacker might try to upload a PHP script masquerading as a JPG, which, if executed, could wreak havoc on your site.
To mitigate this risk, WordPress maintains a list of allowed file types and blocks everything else by default. The allowed extensions include:
| File Type | Extensions |
|---|---|
| Images | jpg, jpeg, png, gif, ico |
| Documents | pdf, doc, docx, ppt, pptx, pps, ppsx, odt, xls, xlsx |
| Audio | mp3, m4a, ogg, wav |
| Video | mp4, m4v, mov, wmv, avi, mpg, ogv, 3gp, 3g2 |
While this default setting helps keep your WordPress site secure, it can sometimes get in the way of legitimate file uploads. That‘s where the "file type not permitted" error comes into play.
When You Might Encounter the Error
So when exactly might you see this pesky error message? The most common scenarios include:
- Trying to upload a file type not listed in the allowed extensions above
- Accidentally adding an extra character or typo in the file extension
- Attempting to upload a file format WordPress doesn‘t recognize
- Running into conflicts with security plugins or web application firewalls
No matter the reason, the result is the same: WordPress blocks the file upload and displays the "Sorry, this file type is not permitted for security reasons" message. Frustrating, right?
Thankfully, there are a few different ways to allow additional file types without compromising your WordPress security. I‘ll walk you through each method step-by-step.
Method 1: Check for Typos in the File Extension
One of the most common causes of the error is simply a mistyped file extension. It‘s easy to accidentally add an extra character or mix up the order, especially with less common formats.
Before attempting the more technical solutions, always double-check your file name and extension. Here‘s how:
On Windows:
- Open File Explorer and navigate to your file
- Click the "View" tab and check the "File name extensions" box
- Verify the file extension matches the format (e.g. .jpg or .pdf)
On Mac:
- Open Finder and find your file
- Right-click the file and select "Get Info"
- Look for the "Name & Extension" section and confirm the extension is correct
If you spot a typo, simply rename the file with the proper extension and try uploading it again. Problem solved!
Method 2: Allow File Types with a Plugin
If your file extension looks good but WordPress still blocks it, you‘ll need to specifically permit that file type. The easiest way to do this is with a plugin.
I recommend using the free "WordPress File Upload" plugin:
- In your WordPress admin dashboard, go to Plugins > Add New
- Search for "WordPress File Upload" and install the plugin by Nickolas Bossinas
- Activate the plugin and go to its Settings page
- In the "Allowed file extensions" field, enter your desired extension (e.g. psd)
- Save your changes
The plugin will handle adding the necessary code snippets to allow your new file type. Just be cautious about enabling too many formats, as it could open up security holes.
After adjusting the settings, return to your Media Library or upload form and try uploading the file again. It should now work without any error messages!
Method 3: Modify Your theme‘s functions.php File
For the more tech-savvy folks out there, you can also permit additional file types by directly editing your theme‘s functions.php file. This method gives you fine-grained control but should only be attempted if you‘re comfortable with PHP.
Here‘s how to allow a new file type using functions.php:
- Back up your WordPress site files and database (seriously, don‘t skip this step!)
- Open up FTP or your hosting file manager and navigate to /wp-content/themes/your-theme/
- Look for the functions.php file and download a copy to your computer
- Open the file in a text editor and paste the following code at the very end:
function custom_upload_mimes($mimes) {
$mimes[‘extension‘] = ‘mime/type‘;
return $mimes;
}
add_filter(‘upload_mimes‘, ‘custom_upload_mimes‘);Replace extension with the file extension (like psd) and mime/type with the matching MIME type (like image/vnd.adobe.photoshop).
You can look up a list of MIME types on the Mozilla Developer Network.
- Save your changes and re-upload the functions.php file, overwriting the original
- Test uploading your newly allowed file type in the Media Library
While this method achieves the same result as the plugin approach, keep in mind that your file type edits will disappear if you ever switch WordPress themes. The changes are specific to your active theme‘s functions.php file.
If you plan to change themes in the future, make sure to copy over your custom code to the new theme‘s functions file to maintain the file upload settings.
Method 4: Update Your WordPress Site‘s .htaccess File
For an even more bulletproof way to allow new file types, you can modify your WordPress site‘s .htaccess file. This method is useful if you‘ve already tried the plugin and functions.php options without success.
Fair warning: Editing your .htaccess file can break your site if done incorrectly. Only proceed if you‘re confident in your ability to follow the steps carefully.
To allow additional file types via .htaccess:
- Thoroughly back up your WordPress files and database
- Connect to your site via FTP or your hosting file manager
- Look for the .htaccess file in your site‘s root directory (the same level as wp-config.php)
- Download a copy of the file to your local machine
- Open the file in a text editor and find the line that starts with
<Files async> - Add the following code on a new line below
<Files async>:
<IfModule mod_mime.c>
AddType extension mime/type
</IfModule>Again, swap out extension and mime/type with your desired file extension and MIME type.
For example, to enable SVG uploads, you would use:
<IfModule mod_mime.c>
AddType svg image/svg+xml
</IfModule>- Save your changes and re-upload the .htaccess file
- Verify your newly allowed file type by uploading it in the Media Library
The changes in your .htaccess file will persist even if you update WordPress or switch themes in the future. It‘s a set-it-and-forget-it solution!
Security Considerations for File Uploads
Now that you know how to allow additional file types in WordPress, it‘s important to understand the security implications. Opening up file uploads always comes with an inherent level of risk.
Here are some of the potential threats to keep in mind:
- Malicious scripts (PHP, JS, Python) could execute on your server
- Macro-enabled Office files (.docm, .xlsm) might run malware
- Hackers can hide backdoors and shells inside innocent-looking files
- Infected files could spread malware to site visitors‘ devices
- Executable files (.exe) may infect your own computer
According to a study by Wordfence, executable file uploads (like PHP scripts) are the fastest growing security threat to WordPress sites. In 2020, they accounted for over 25% of all attempted attacks.
So what can you do to protect your site while still allowing necessary file types? Here are some expert tips:
- Only enable file extensions you absolutely need
- Restrict uploads to trusted user roles like admins and editors
- Install a WordPress security plugin to monitor for malicious files
- Regularly scan your site for malware and backdoors
- Implement a firewall and IP blocking rules
- Keep your WordPress core, themes, and plugins up to date
- Run your site over HTTPS with an SSL certificate
By combining file type restrictions with proactive security measures, you can greatly reduce the risk of a successful attack.
Frequently Asked Questions
Before we wrap up, let‘s address some common questions about the "file type not permitted" error:
What‘s the difference between a file extension and MIME type?
A file extension is the 2-4 letter code at the end of a filename, like .jpg or .pdf. A MIME type is a more specific identifier used by browsers and servers to determine how to handle a file. An example MIME type is image/jpeg.
Can I allow different file types for specific user roles?
Absolutely! Plugins like User Role Editor let you set granular file type permissions based on user roles and capabilities. For instance, you could allow PDF uploads for all users but restrict SVGs to only administrators.
Why can‘t I upload a file even after allowing its type?
If you‘re still seeing the error after following the steps above, it‘s possible your hosting environment or security plugin is overriding your file type settings. Reach out to your host‘s support team or temporarily disable your security plugins to troubleshoot.
Wrapping Up
Whew, that was a lot to cover! Let‘s recap what we‘ve learned about fixing the "Sorry, this file type is not permitted for security reasons" error in WordPress:
- WordPress blocks certain file types by default to protect your site from malicious uploads
- The error message appears when you try to upload a file extension not on the allowed list
- You can fix the error by checking for typos, using a plugin, editing functions.php, or modifying .htaccess
- Always consider the security implications of allowing new file types
- Implement security best practices like user role restrictions and malware scanning
I hope this in-depth guide has given you the knowledge and confidence to tackle this common WordPress error. Remember, the goal is to strike a balance between flexibility and security.
By carefully choosing which file types to allow and staying vigilant about potential threats, you can keep your WordPress site running smoothly and securely.
If you found this guide helpful, be sure to share it with your fellow WordPress users. And if you have any lingering questions, feel free to leave a comment below. I‘m always happy to help out a fellow WordPresser!
Until next time, happy uploading!
