Allow Different File Types and Bypass Security Alert

WordPress supports a bunch of different file types already, but working within different industries, and creating online databases / libraries for clients requires the need for the addition of file types that are not supported by WordPress.

You could install plugins to handle these file types for you, or you can setup some code to address the issues on your own.

First, in functions.php add your file types to the following function:

add_filter('upload_mimes','add_custom_mime_types');
function add_custom_mime_types($mimes){
return array_merge($mimes,array (
'svg' => 'image/svg+xml',
'pat' => 'image/pat',
));
}

If you’re still seeing a security warning for WordPress, add the following snippet to wp-config near the “That’s it! Happy Blogging!” line:

define('ALLOW_UNFILTERED_UPLOADS', true);

These two items combined will allow you upload any file type.

Sources:

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.