---
title: "How to Upload Additional File Types in WordPress"
description: "WordPress only allows uploading certain file types to the media library, but changing this behavior is very easy. Learn to do it yourself."
url: https://neliosoftware.com/blog/how-to-upload-additional-file-types-in-wordpress/
date: 2016-09-29
modified: 2018-04-06
author: "Antonio Villegas"
image: https://neliosoftware.com/wp-content/uploads/2016/09/files.jpeg
categories: ["WordPress"]
tags: ["Resources", "Tutorials", "WordPress Advanced"]
type: post
lang: en
---

# 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](https://neliosoftware.com/blog/top-5-problems-solved-with-nelio-content/) 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](https://neliosoftware.com/blog/wordpress-is-great-for-small-and-medium-enterprises/) 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](https://codex.wordpress.org/Uploading_Files), contact your provider first to get an explanation.

![When trying to upload a .SVG image in WordPress you get an error.](https://neliosoftware.com/wp-content/uploads/2016/09/error-uploading-files.png)![When trying to upload a .SVG image in WordPress you get an error.](https://neliosoftware.com/wp-content/uploads/2016/09/error-uploading-files.png)*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:

`define( 'ALLOW_UNFILTERED_UPLOADS', true );`

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](https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes).

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:

View the code on [Gist](https://gist.github.com/avillegasn/9d2328c06dfad61c9891731f64d3b97c).
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](https://www.iana.org/assignments/media-types/media-types.xhtml) 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 `unset`ting their entries in the `$mime_types` array, as I did in lines 7 and 8, where I disabled Microsoft Excel file uploading.

![](https://neliosoftware.com/wp-content/plugins/nelio-addons/partials/blog-ads/testing/assets/background.jpg)![](https://neliosoftware.com/wp-content/plugins/nelio-addons/partials/blog-ads/testing/assets/background.jpg)

## Nelio A/B Testing

I was very impressed by the quality of this plugin, how easy it was to set up, and the outstanding support Nelio provides. I highly recommend Nelio A/B Testing.

![](https://neliosoftware.com/wp-content/plugins/nelio-addons/partials/blog-ads/testing/assets/josette.jpg)![](https://neliosoftware.com/wp-content/plugins/nelio-addons/partials/blog-ads/testing/assets/josette.jpg)

Josette Millar

[WordPress.org](https://wordpress.org/support/topic/excellent-plug-in-with-outstanding-support-2/)

[View Plans](https://neliosoftware.com/testing/pricing/)

## Summary

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.

*Featured image by [Andrew Pons](https://unsplash.com/search/files?photo=6-RhsUzKO6g).*
