You are here: Blog » Code Snippets » WordPress Add Allowed File Types

WordPress Add Allowed File Types

ft

The WordPress media uploader is a great tool that allows you to easily include images, videos, documents, and audio on your site. One of the security features associated with the WordPress media uploader is that you are only allowed to upload specific file types. The reason this restriction is in place is primarily to keep your site protected from potentially harmful files. This WordPress Add Allowed File Types tutorial will show you how you can include additional filetypes in your list of allowed uploadable files.

Sometimes though for whatever reason you want to be able to use the handy WordPress media uploader tool to upload disallowed file types on your site. Here is a snippet which demonstrates how to do this.

Add the following code to your themes functions.php file:

 

In the example above, I make it so that I can upload files with extension *.vcf. The ‘text/vcard’ part of the code refers to the MIME type for your desired file type. Refer to this page to look up the MIME type for the filetype you wish to support. You could also just try googling it.

If you want to allow ALL filetypes, you could add the following line to your wp-config.php file.

I prefer the first method however because you are still limiting the file types allowed on your site, vs the second method where you open up the floodgates to every possible file type, including many potentially dangerous ones.

 

This entry was posted in Code Snippets and tagged , by .

Author: justin saad

Justin Saad is first and foremost a husband and a father of four. He is also a web developer and designer who has been making websites for over twenty years. His company is called The Motech Network and his website is ClevelandWebDeveloper.com. In addition to building websites, Justin makes WordPress plugins and likes writing tutorials to help others learn about various aspects of web development.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">