< Back to Coding, WordPress

Allowing WordPress to accept more uploadable file formats

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 *