DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

For some reason, WordPress uploader won’t let you upload some filetypes, such as Textmate’s .tmCommand. If you need to upload those files to your WordPress blog, here is a very nice snippet that will allow you to do it.

Simply paste the following code on your functions.php file. If needed, you can add more file types by adding them on line 4, separated by a pipe (|)

<?php
function addUploadMimes($mimes) {
    $mimes = array_merge($mimes, array(
        'tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences' => 'application/octet-stream'
    ));
 
    return $mimes;
}
?>

add_filter('upload_mimes', 'addUploadMimes');

Thanks to Pioupioum for this great piece of code!

By the way, I’m running a contest at CatsWhoBlog where you can win premium WordPress themes. Click here to join!

Tags

3 Comments

  1. Thanks so much for this piece of code! You just saved me an hour or more of trial and error to get wordpress to accept other formats. Thanks again.

  2. bluantinoo

    sorry but it does not seems to work on WP 3.3.x

  3. where in the file do you add it? I tried adding it at the end but it seems to put a error message at the top of the page when I reload it.

Leave a Comment

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