You are customizing your WordPress site and try to upload a crisp `.svg` vector logo, a `.json` layout template, a `.woff2` web font, or an `.ico` favicon into the Media Library—only to be stopped by the error: “Sorry, this file type is not permitted for security reasons.”
Here is why WordPress blocks certain extensions and how to allow the exact file types you need safely.
Outgrowing Free Hosting Limits? Claim Our Partner Discounts
Upgrade to fast Hostinger LiteSpeed WordPress Hosting (with an extra 20% referral discount + free domain) or grab low-cost Namecheap cPanel Hosting & Domains with free WHOIS privacy:
Method 1: Whitelist Specific Extensions Using the `upload_mimes` Filter (Safest)
Instead of turning off all upload security checks, add this clean filter to your child theme’s functions.php (or a lightweight Code Snippets plugin) to allow `.json`, `.woff2`, and `.webp` files for administrators:
add_filter( 'upload_mimes', function( $mimes ) {
if ( current_user_can( 'manage_options' ) ) {
$mimes['json'] = 'application/json';
$mimes['woff2'] = 'font/woff2';
$mimes['webp'] = 'image/webp';
}
return $mimes;
} );*(Tip: Always validate any `.json` file before uploading it using our Free JSON Formatter & Syntax Validator!)*
Method 2: Temporary `ALLOW_UNFILTERED_UPLOADS` in `wp-config.php`
If you just need to upload one trusted file right now and move on:
- Open
wp-config.phpin cPanel File Manager and adddefine( 'ALLOW_UNFILTERED_UPLOADS', true );above “That’s all, stop editing”. - Upload your file in Media → Add New.
- Delete that line from `wp-config.php` immediately afterward so your site stays locked down!
Frequently Asked Questions (FAQ)
Why does WordPress block SVG, JSON, or font files in the Media Library?
WordPress restricts Media Library uploads to a pre-approved whitelist of safe file extensions (like .jpg, .png, .webp, .pdf, and .mp4) to prevent attackers from uploading executable scripts disguised as media files.
Is ALLOW_UNFILTERED_UPLOADS in wp-config.php safe to leave enabled?
Only enable define(‘ALLOW_UNFILTERED_UPLOADS’, true) temporarily while uploading a trusted file as an Administrator, then remove the line immediately afterward so other accounts cannot upload dangerous files.
How do I permanently allow specific file types like .json or .woff2 in WordPress?
Use the upload_mimes filter inside your theme’s functions.php or a code snippets plugin to whitelist only the specific file extension and MIME type you need.