Post Pic

WordPress tip: allow upload of more file types

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!

8 Responses

Mar 22 2010 08:15

The piece of code saved my day and the code is working perfectly , thanks for sharing

Mar 22 2010 16:11

Thanks for the tip. I just found your website, and it’s bookmarked! Good stuff.

Mar 22 2010 16:37

There is some mistakes on closed ?> tag, the tag need to be placed in the end of the code ;)

Mar 22 2010 20:36

Thanks Jean, but as Jauhari said move the closing php tag after adding the filter :)

Mar 30 2010 12:22

Thanks for the helpful upload tip, much appreciated.

Aug 22 2010 12:42

Hello. I`m so sorry for my comment and my english, but can you help me?
i`m doing site, but there is small problem, when read a post on my site the categories must be on rel=”nofollow”,and it must be only on single pages. But in site.com/category/music links must be without rel=”nofollow”
How realize it?

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required