Allowing WordPress to accept more uploadable file formats

Posted on

in

,

I was trying to update a html file I uploaded and got the error:

File type does not meet security guidelines. Try another.

Very annoying. Luckily googling led me to the solution fairly easily. In the functions.php file in your theme add this

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
    // add your extension to the array
    $existing_mimes['html'] = 'text/html';
    // removing existing file types if you want (commented out atm)
    //unset( $existing_mimes['exe'] );
    return $existing_mimes;
    }

In the example I added HTML to the list of accepted file types. To find more file formats go to http://en.wikipedia.org/wiki/Internet_media_type

 

Leave a Reply

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

About me

Mark Wong is a front end developer with 10+ years experience. Most of his knowledge of HTML5, CSS and Js is self taught.

Calendar

October 2024
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031