How to Upload Additional File Types in WordPress

Being able to manage all the files we upload in WordPress in one place (the media library) is something very useful. Some say the media library could be improved—some requested features are still missing, like file tagging, sorting by topic or by file extension, or searching for duplicates—, but its usefulness is clear when reusing or sharing files between our contents without having to upload them more than once.

Maybe you didn’t know that, but WordPress only allows file uploading into the media library if such files meet certain conditions. Specifically, you can only upload the following file types by default in a standard WordPress installation:

  • Images
    • .jpg
    • .jpeg
    • .png
    • .gif
    • .ico
  • Documents
    • .pdf (Portable Document Format; Adobe Acrobat)
    • .doc, .docx (Microsoft Word Document)
    • .ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
    • .odt (OpenDocument Text Document)
    • .xls, .xlsx (Microsoft Excel Document)
    • .psd (Adobe Photoshop Document)
  • Audio
    • .mp3
    • .m4a
    • .ogg
    • .wav
  • Video
    • .mp4, .m4v (MPEG-4)
    • .mov (QuickTime)
    • .wmv (Windows Media Video)
    • .avi
    • .mpg
    • .ogv (Ogg)
    • .3gp (3GPP)
    • .3g2 (3GPP2)

However, it’s not always possible to upload all these file types—some hosting providers limit the set of valid file types and even the maximum file size you can upload in your installation. If you have problems uploading some permitted file types, contact your provider first to get an explanation.

When trying to upload a .SVG image in WordPress you get an error.
When trying to upload a .SVG image in WordPress you get an error.

Recently we received a comment asking us how to expand the list by adding more file types. As surely there are more people interested in learning how to do this, in this post I explain the solution.

Modiying wp-config.php

If you do not want to limit the file types and thus upload any file into the media library, the easiest way to follow is to add the following line in the wp-config.php file:


The wp-config.php file allows us to modify the default behavior of WordPress. You’ll find it in the root of your server. Using the above statement we are allowing all administrators to upload any file type. Note that this can be dangerous if you do not trust too much your administrators and what they can do. Be careful when adding this statement or you might end up regretting your decision 🙃

Using the upload_mimes filter

If you want to solve the problem of uploading additional file types to WordPress, but being selective and only allowing a controlled subset of file types, the best you can do is use the upload_mimes filter. As always, you have all the information in the Codex.

This filter is super easy to use. You only need to add a piece of code similar to the following in the functions.php file of your theme or inside a new plugin of your own:

add_filter( upload_mimes, my_myme_types, 1, 1 );
function my_myme_types( $mime_types ) {
$mime_types[svg] = image/svg+xml; // Adding .svg extension
$mime_types[json] = application/json; // Adding .json extension
unset( $mime_types[xls] ); // Remove .xls extension
unset( $mime_types[xlsx] ); // Remove .xlsx extension
return $mime_types;

You can ignore the first line (<?php), which simply opens a block of PHP code. Line 2 indicates that the function my_mime_types will be executed with the upload_mimes filter. Lines 3 to 10 define this function. my_mime_types has one single parameter ($mime_types)—the list of allowed file types.

If you want to allow SVG and JSON files in the media library, just add lines 4 and 5, respectively. This is how it works: to add a new file type, you just have to create a new entry in the $mime_types list with the file extension and mime type. To find the proper mime type of an extension go to the official list of media types that the IANA (Internet Assigned Numbers Authority) defines.

On the other hand, you can also disable certain file types. You can prohibit the file types you want by simply unsetting their entries in the $mime_types array, as I did in lines 7 and 8, where I disabled Microsoft Excel file uploading.


As you can see here, modifying the default behavior of WordPress to have greater control over the file types you allow in your installation is very simple. And best of all, you don’t need to install a complex plugin for this. With just a few lines of PHP code or even editing the wp-config.php file you’ll get what you want.

Now it’s your turn. Explain us which file types you miss in WordPress and your experience using the solutions I have proposed in this article.


Thank you for reading this blog and welcome back again! We are happy to see you here.  Did you like this post? Kindly share the post using the buttons below. Drop your comments below in the comment box. 

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

%d bloggers like this: