search ]

How to Enable the Upload of Additional File Types in WordPress?

For security purposes, WordPress only allows uploading common file types such as images, videos, and documents. But sometimes you need to upload a file with an extension that WordPress blocks by default – like SVG, PSD, or a custom format.

In this guide, you’ll learn how to allow additional file types, how to block specific types, and the security implications of each approach.

WordPress determines allowed file types based on MIME types. A MIME type is a label like image/png or application/pdf that identifies the format of a file. WordPress maintains an internal allowlist of MIME types, and any file that doesn’t match is rejected during upload.

Default Allowed File Types

WordPress allows most common file types out of the box, including:

  • Images: JPG, JPEG, PNG, GIF, ICO, WEBP (since WP 5.8), AVIF (since WP 6.5)
  • Documents: PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, ODT, PPS
  • Audio: MP3, M4A, OGG, WAV
  • Video: MP4, MOV, AVI, WMV, MPEG, OGV, 3GP, WebM

The full list is defined in the wp_get_mime_types() function in WordPress core. For a complete reference, see the official documentation.

How to Allow Additional File Types

To allow additional file types, use the upload_mimes filter. Add this code to your child theme’s functions.php file:

add_filter( 'upload_mimes', function( $mime_types ) {
    $mime_types['svg']  = 'image/svg+xml';
    $mime_types['psd']  = 'image/vnd.adobe.photoshop';
    $mime_types['ai']   = 'application/postscript';
    $mime_types['eps']  = 'application/postscript';
    return $mime_types;
} );

Each line adds a file extension mapped to its MIME type. To find the correct MIME type for a format, search for it on the IANA Media Types registry.

Here are some commonly requested MIME types:

ExtensionMIME TypeDescription
.svgimage/svg+xmlScalable Vector Graphics
.psdimage/vnd.adobe.photoshopAdobe Photoshop
.ai / .epsapplication/postscriptAdobe Illustrator / PostScript
.jsonapplication/jsonJSON data files
.woff / .woff2font/woff / font/woff2Web fonts

SVG Security Warning: SVG files are XML-based and can contain embedded JavaScript, making them a potential XSS (cross-site scripting) attack vector. If you allow SVG uploads, only grant upload permissions to trusted users, or use a plugin like Safe SVG that sanitizes files on upload.

Allow All File Types (Not Recommended)

Another approach is to remove all file type restrictions by adding this constant to your wp-config.php file:

define( 'ALLOW_UNFILTERED_UPLOADS', true );

Security Risk: This allows any file type to be uploaded, including executable files like .php, .exe, or .sh. A malicious user with upload access could upload a PHP shell and take full control of your server. Only use this in development environments, never on a production site.

How to Block a Specific File Type

If you want to prevent a specific file type from being uploaded, use the same upload_mimes filter with unset():

add_filter( 'upload_mimes', function( $mimes ) {
    unset( $mimes['gif'] );
    return $mimes;
} );

This removes GIF from the allowed types. You can unset any key from the $mimes array to block that format.

Plugin Alternatives

If you prefer not to edit code, several plugins handle this:

  • WP Extra File Types – Adds a settings page where you can check/uncheck allowed file types without writing code
  • Safe SVG – Specifically enables SVG uploads while sanitizing the files to remove potentially malicious code
  • WP Add Mime Types – Lets you add custom MIME types from the WordPress admin

Troubleshooting Upload Errors

If you’ve added a file type but uploads still fail, check these common causes:

  • File size limit: Your server’s upload_max_filesize and post_max_size PHP settings may be too low
  • Multisite restrictions: On WordPress Multisite, only Super Admins can upload unfiltered files. The network settings also have a separate allowed file types list under Network Admin > Settings
  • Server-level blocking: Your web server (Apache/Nginx) or a security plugin like Wordfence may block certain file types regardless of WordPress settings
  • File validation: Since WordPress 4.7.1, uploaded files are validated against their actual content, not just their extension. A file with a mismatched extension and content will be rejected

For more image-specific upload issues, see the guide on troubleshooting WordPress image upload errors.

FAQs

Common questions about WordPress file uploads:

Why does WordPress restrict file uploads?
WordPress restricts file uploads for security. Allowing unrestricted uploads could let malicious users upload executable files (like PHP scripts) that could compromise your server. By maintaining an allowlist of safe MIME types, WordPress ensures that only known file formats can be uploaded through the Media Library.
Is it safe to upload SVG files in WordPress?
SVG files are XML-based and can contain embedded JavaScript, making them a potential XSS attack vector. If you allow SVG uploads, use a plugin like Safe SVG that sanitizes the file content on upload. Only grant upload access to trusted users, and never allow SVG uploads from untrusted sources like a public-facing form.
Does WordPress support WEBP and AVIF images?
Yes. WEBP has been supported natively since WordPress 5.8 (2021), and AVIF support was added in WordPress 6.5 (2024). You do not need to add custom code or plugins to upload these formats - they work out of the box on supported servers. Your server must have the appropriate image library (GD or Imagick) with support for these formats.
How do I find the MIME type for a specific file format?
The official registry of MIME types is maintained by IANA at iana.org/assignments/media-types. You can also check a file's MIME type on Linux/Mac by running file --mime-type filename in the terminal. Common examples include image/svg+xml for SVG, application/json for JSON, and font/woff2 for WOFF2 web fonts.
Should I use ALLOW_UNFILTERED_UPLOADS on my site?
No, not on a production site. ALLOW_UNFILTERED_UPLOADS removes all file type restrictions, allowing any file - including PHP scripts and executables - to be uploaded. This is a critical security risk. Instead, use the upload_mimes filter to selectively allow only the specific file types you need. Reserve ALLOW_UNFILTERED_UPLOADS for local development environments only.

Summary

WordPress restricts file uploads to a safe list of MIME types for security. To allow additional types, use the upload_mimes filter in your child theme’s functions.php to add specific extensions.

Avoid using ALLOW_UNFILTERED_UPLOADS on production sites, as it removes all restrictions and creates a serious security vulnerability. For SVG files specifically, use a sanitization plugin like Safe SVG to prevent XSS attacks.

Modern WordPress versions support WEBP (since 5.8) and AVIF (since 6.5) natively – no custom code needed for these formats.

Join the Discussion
2 Comments  ]
  • Nuge 26 March 2025, 20:49

    I added define( ‘ALLOW_UNFILTERED_UPLOADS’, true ); to the wpconfig file and it is still blocking me

    • רועי יוסף 30 March 2025, 19:42

      maybe its an issue with the type quotes you’ve used? try to copy and paste this:

      define( 'ALLOW_UNFILTERED_UPLOADS', true );

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo