Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Add and Fix MIME Types in WordPress

A practical WordPress guide to adding MIME types with upload_mimes, understanding mime_types, fixing upload errors, handling Multisite restrictions, and validating files securely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use WordPress’s upload_mimes filter to allow a specific extension/MIME pair, keep the rule in a plugin or site-specific functionality module, and then test a real upload. If the site is on Multisite, a Super Admin must also permit that extension under Network Admin → Settings → Upload file types. When an upload still fails, inspect the active allowlist, the file’s actual contents, and any form, security, web-server, or hosting rules outside WordPress core.

What a MIME type controls in WordPress

A MIME type describes the format of a file, while the extension is the suffix in its name. A JSON file normally has the .json extension and the application/json MIME value. WordPress uses an extension-to-MIME map when it decides whether an upload is acceptable; the extension alone is not the complete security decision.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The core map contains common image, audio, video, document, archive, and OpenDocument formats. Its contents can change with WordPress releases, so code should inspect the current map rather than assume that a type is permanently present.

  • wp_get_mime_types() returns the general extension-to-MIME map.
  • get_allowed_mime_types() returns the types currently allowed for an upload context.
  • wp_check_filetype( $filename, $mimes = null ) matches a filename against a map and returns ext and type. If there is no match, those values are false.
  • wp_check_filetype_and_ext( $file, $filename, $mimes = null ) performs the mapping and, for images, tries to determine the real MIME type. It can return a corrected image filename when the extension does not match the content.

That distinction matters: adding a name to a list does not make arbitrary bytes safe. A secure implementation allows only the formats the site needs and validates the uploaded content before it is stored or processed.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose the right WordPress hook

Hook or setting What it changes Best use Important limitation
upload_mimes The upload allowlist used by a site Adding one or more extensions, or removing an extension from uploads It does not by itself prove that file bytes match the claimed format
mime_types The general extension-to-MIME map Adding a mapping that other WordPress code can read WordPress documents this filter for adding types, not for removing them; use upload_mimes to restrict uploads
Multisite network setting A network-wide ceiling on uploadable extensions Letting a Super Admin control what individual sites may upload A site-level filter cannot widen a type that the network has excluded
Form, security, server, or host rule An additional layer outside core upload handling Diagnosing failures after WordPress accepts the type Each layer has its own configuration and logging

For a normal site-level change, start with upload_mimes. Use mime_types only when you intentionally need to extend the general map for code that reads it independently of the upload allowlist.

Add one MIME type with upload_mimes

Put a narrow rule in a small custom plugin or another site-specific functionality location. That keeps the change when the active theme changes and makes it possible to audit or remove the rule without editing WordPress core.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
/**
 * Plugin Name: Site upload MIME rules
 */

add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['json'] = 'application/json';
    return $mimes;
} );

Save the file as a PHP plugin in the site’s wp-content/plugins directory, activate it in the Plugins screen, and replace the example pair with the exact extension and MIME value required by your format. Do not add a wildcard or a rule that accepts every extension.

If the functionality is already managed in a site-specific plugin, add the filter there instead of creating a second plugin. A child theme’s functions.php can also hold the filter, but a theme change then removes the behavior; a functionality plugin is usually easier to audit and deploy.

Allow several documented formats in one rule

add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['json'] = 'application/json';
    $mimes['csv']  = 'text/csv';
    $mimes['svg']  = 'image/svg+xml';
    $mimes['webp'] = 'image/webp';
    return $mimes;
} );

Keep each entry explicit. If a format has more than one legitimate extension, add each extension deliberately and document why it is needed. Do not assume that a browser’s reported content type is trustworthy; WordPress still needs to inspect the file during the upload process.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Inspect the active map before changing code

A frequent cause of confusion is testing against a map that is different from the one used by the upload request. You can inspect the effective allowlist from a temporary administrative diagnostic, a controlled debugging endpoint, or a command-line bootstrap that loads WordPress:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$allowed = get_allowed_mime_types();
error_log( print_r( $allowed, true ) );

Search the resulting array for the extension you need. The keys may contain several extensions separated by a pipe character, so look for the exact entry rather than assuming one key equals one suffix. Remove diagnostic output after testing; exposing the complete list to unauthenticated visitors is unnecessary.

To check a filename against a supplied map:

$result = wp_check_filetype( 'sample.json', get_allowed_mime_types() );
// $result['ext'] is 'json' and $result['type'] is 'application/json'
// when the current map permits that pair.

A false ext or type means that the filename did not match the map passed to the function. It does not prove that the file is corrupt; it indicates that the current allowlist or extension is wrong.

Fix “Sorry, this file type is not permitted for security reasons”

Work through the checks in order. Changing several layers at once makes it difficult to identify the real restriction.

1. Confirm the pair you intend to allow

  1. Write down the exact extension, without the leading dot, and the MIME string required by the format.
  2. Check that the filename has only the expected final extension. A name such as report.json.exe must not be treated as JSON.
  3. Confirm that your filter is loaded on the request that performs the upload. A plugin that is inactive, placed in the wrong directory, or guarded by an admin-only condition will not change the allowlist.

2. Check the effective allowlist

Use get_allowed_mime_types() in a controlled diagnostic and verify that the extension appears with the intended MIME value. If it is absent, correct the filter before investigating the file itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

3. Check Multisite network restrictions

On Multisite, WordPress applies the network’s permitted extension list as an additional limit. A Super Admin should open Network Admin → Settings → Upload file types and add the extension there if network policy allows it. Core’s check_upload_mimes() intersects the general map with the network upload_filetypes option. The documented default for that option is jpg jpeg png gif; a site-level filter cannot expand a network list that omits the requested type.

4. Check the bytes and image metadata

If the extension appears in the map but the upload is rejected, compare the file’s real contents with its name. WordPress’s wp_check_filetype_and_ext() performs the normal mapping and, for images, attempts to determine the actual MIME type. It can reject an extension/content mismatch or return a corrected filename for an image.

if ( ! function_exists( 'wp_check_filetype_and_ext' ) ) {
    require_once ABSPATH . 'wp-admin/includes/file.php';
}

$check = wp_check_filetype_and_ext(
    $path_to_uploaded_file,
    $original_filename,
    get_allowed_mime_types()
);

if ( empty( $check['ext'] ) || empty( $check['type'] ) ) {
    // Reject the upload and record a useful, private diagnostic.
}

The include is important when this function is called from a plugin or theme and the function has not already been loaded.

5. Look beyond WordPress core

A form builder may maintain its own extension list. A security plugin, web server, reverse proxy, or hosting policy may also block a type after WordPress has accepted it. Compare the browser’s error with the PHP error log and the server response, and review those products’ allowlists one at a time. Do not weaken WordPress validation merely to bypass an unrelated layer.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate custom uploads securely

The media-library path is not the only place files enter a site. A custom form or REST endpoint must perform its own checks before moving a temporary file into permanent storage.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  1. Sanitize the name first. Apply WordPress filename sanitization before examining the extension. This removes unsafe characters and reduces ambiguity in names supplied by a user.
  2. Use an allowlist. Accept only the exact extensions and MIME values required by the feature. An “allow everything” policy turns a convenience fix into an execution and content-delivery risk.
  3. Check both name and content. Use wp_check_filetype() for the extension-to-MIME decision and prefer wp_check_filetype_and_ext() when image content needs verification.
  4. Keep storage and permissions appropriate. A file that contains markup or script-like content needs additional sanitization and access controls; merely labeling it with an image MIME type is not a sanitizer.
  5. Log rejections without exposing internals. Record the extension, detected type, and reason in a private log, but return a generic message to an unauthenticated uploader.

Do not enable ALLOW_UNFILTERED_UPLOADS for a routine fix. That constant bypasses the narrow allowlist model and should not be a substitute for identifying the one format the feature actually needs.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common recipes and their cautions

JSON

For configuration or data files, the usual pair is json and application/json. Keep access controls in mind: JSON can disclose application data even though it is not normally executable.

add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['json'] = 'application/json';
    return $mimes;
} );

CSV

Comma-separated files commonly use csv and text/csv. If the file will later be opened in a spreadsheet, treat imported cell content as untrusted data and validate it in the importing feature; allowing the upload does not validate rows or formulas.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['csv'] = 'text/csv';
    return $mimes;
} );

WebP

WebP images use webp and image/webp. Confirm that the installed WordPress and image-processing stack can generate the sizes your site needs after the file is accepted. If the file is renamed from another format, content validation still has to pass.

add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['webp'] = 'image/webp';
    return $mimes;
} );

SVG and SVGZ

SVG is XML and can contain active or externally referenced content; SVGZ is its compressed form. If you decide to permit either, add only the required extension and put sanitization, who-can-upload rules, and serving controls in place. A MIME filter alone does not make an SVG safe.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
add_filter( 'upload_mimes', function ( $mimes ) {
    $mimes['svg']  = 'image/svg+xml';
    $mimes['svgz'] = 'image/svg+xml';
    return $mimes;
} );

When to use mime_types instead

WordPress describes mime_types as a filter for adding entries to the general MIME map. Its documented guidance is: “This filter should be used to add, not remove, mime types. To remove mime types, use the ‘upload_mimes’ filter.” That makes it useful when another part of your code calls wp_get_mime_types() and needs to see a new mapping, but it is not the usual control for restricting uploads.

add_filter( 'mime_types', function ( $mimes ) {
    $mimes['json'] = 'application/json';
    return $mimes;
} );

Adding the same pair to both filters is usually unnecessary. Start with the upload filter, then add the general-map filter only when a specific integration demonstrably requires it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compare the ways to manage a MIME rule

Approach Scope Map or allowlist Content validation Who can upload Removal and audit
Site-specific plugin using upload_mimes One site Changes the upload allowlist Use WordPress validation functions separately Any role already permitted to upload, subject to WordPress capabilities Deactivate or delete one documented rule
Theme or child-theme code One site while that theme is active Changes the upload allowlist Use WordPress validation functions separately Existing upload-capable users Can disappear during a theme change; harder to audit as site functionality
Network setting on Multisite All sites in the network Caps the extensions available to sites Core still performs its normal checks Controlled by each site’s capabilities after the network permits the type Changed by a Super Admin in Network Admin
Generic MIME-management plugin Depends on its configuration; may be site or network wide May alter the map, the upload allowlist, or both Verify whether it checks file contents; do not assume it does Depends on plugin and WordPress capabilities Review settings, exported configuration, and plugin deactivation behavior
Hosting or web-server rule Server, virtual host, or account Usually an additional restriction Often outside WordPress’s validation functions All requests reaching that layer Requires server-level documentation and change control

Test the change without weakening security

  1. Back up the plugin or site-specific code and note the original allowlist.
  2. Activate the narrow filter and reload the upload screen.
  3. Upload a genuine sample of the intended format, not a file that was merely renamed.
  4. Confirm that WordPress stores the file, records the expected extension and MIME value, and generates any required metadata.
  5. Try a deliberately mismatched sample in a controlled environment and confirm that validation rejects it.
  6. Repeat the test as the roles that should and should not have access, especially on Multisite.
  7. Review PHP and web-server logs, then remove temporary diagnostics and test files.

For a production rollout, record the extension, MIME value, business reason, approving administrator, date, and removal plan. That small audit trail prevents an old exception from becoming a permanent, forgotten attack surface.

Remove or roll back a MIME change

Delete the specific array entry from the plugin, or deactivate the plugin that owns it, then clear any object or page cache that could leave an old upload form visible. If the type was also added to a Multisite network’s upload list, a Super Admin must remove it there separately. Existing files are not automatically deleted when a MIME rule is removed; decide how those files should be retained, quarantined, or served before changing the policy.

The safest long-term configuration is therefore small and explicit: one documented filter, one required extension/MIME pair, normal WordPress content checks, and a network-level review when Multisite is involved.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.