post icon

WordPress File Upload Error Security Fix

This is an UPDATE to snuff out all the whiny people that have been complaining about how this?‘old school fix’ isn’t the right way. When I wrote this it was around 5 years ago before wordpress had any nifty ways to get around this and before there were any cool plugins to solve the issue.

New ways

Thanks to @mikes comment… you can add this into your themes functions.php file which will allow text/x-vcard

add_filter(?upload_mimes?,'add_vcard_upload_support?));
function add_vcard_upload_support($mimes) {
$mimes['vcf|vcard'] = ?text/x-vcard?;
return $mimes;

Or you can just install a plugin like: http://wordpress.org/extend/plugins/pjw-mime-config/

Old way

Here’s how to fix the “WordPress File Type does not meet security guidelines” error you get from trying to upload certain files.

First find out what the mime type of the file you were trying to upload is. You can go to w3schools or mozdev

Write down the file type ie: (application/x-shockwave-flash, or video/x-m4v) you also need the extension ie: (swf or m4v)

For WP 2.0 and up open up the wp-includes/functions.php file and goto around line 1069 All you have to do is follow the coding conventions in there and add your file types you want. Because they use a foreach loop to go through all the listed file types you can add as many as you like as long as they follow the convention there. For older versions of WP I think the correct file is: wp-admin/admin-functions.php

Look for this:

function wp_check_filetype($filename, $mimes = null) {
 // Accepted MIME types are set here as PCRE unless provided.
 $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array (
  'vcf' => 'text/x-vcard',
  'jpg|jpeg|jpe' => 'image/jpeg',
??'gif' => 'image/gif',
??'png' => 'image/png',
??'bmp' => 'image/bmp',
??'tif|tiff' => 'image/tiff',

16 Comments

Leave a comment
  1. Kristof Coomans
    14. Feb, 2007 at 12:59 am #

    Hi Darren

    This is a possible fix, but it doesn’t make upgrading easier. You will have to backup your changes and apply them again after upgrading.

    To my opinion, the pjw-mime-config is a more robust solution.

    Also see http://blog.coomanskristof.be/2006/10/24/wordpress-upload-file-type-security-restrictions/

  2. Darren Terhune
    14. Feb, 2007 at 4:37 am #

    It’s always good to have more than one way to fix a problem! Thanks for the link Kristof.

  3. Louis Hearn
    09. Aug, 2007 at 5:59 am #

    Depending on the type of file you want to make available, you can also provide it as a ZIP file for download.

    WordPress wouldn’t let me upload Photoshop actions or setting files, but once they were in a ZIP file they uploaded, displayed in “Browse All” and downloaded fine.

    Obviously this is not a solution for things like videos that you want to display directly on your page, but since I found your blog while trying to solve this particular problem, I wanted to add it to the list.

  4. Darren Terhune
    09. Aug, 2007 at 1:54 pm #

    @Louis
    That is a possible fix for sure… but like you said I do a lot of video stuff and that was the reason I posted this, cause it’s really easy to fix and you don’t have to add any plugins… Thanks Louis.

  5. Ian B
    03. Jun, 2009 at 9:29 am #

    I tried the PJW plugin for a while, but dropped that thing like a hot potato after it filled the blog options table with tens of thousands of duplicate entries containing those mimetypes.

  6. Darren Terhune
    08. Jun, 2009 at 12:11 am #

    @Ian B… I wonder if that plugin was broken after upgrading wordpress? I like my own code… means I know wtf is going on.

  7. Affeld
    09. Sep, 2009 at 3:19 am #

    I tried the PJW plugin for a while, but dropped that thing like a hot potato after it filled the blog options table with tens of thousands of duplicate entries containing those mimetypes….

  8. New Blogger
    06. May, 2010 at 5:00 pm #

    Where do you find the “wp-includes/functions.php file”

  9. Darren Terhune
    06. May, 2010 at 5:10 pm #

    @New Blogger If you only have a yoursite.dreamhost.com blog I don’t think you can modify this file… you have to manage your own hosting and install wordpress manually or through your web host to be able to mod this file. If you download wordpress from http://wordpress.org then you can find the file I’m talking about.

  10. Mike Schinkel
    06. Sep, 2010 at 2:07 am #

    Hi Darren:

    I’m sure you are not aware but you are doing your readers and the WordPress community a huge disservice with this post. You should never recommend that readers modify core WordPress code because it will be wiped out when they upgrade. This can have a chilling effect; WordPress users who follow your advice will become afraid to upgrade later because when they do upgrade their WordPress will “break” in their eyes and it will give them a bad taste in their mouth. And they won’t blame you, they’ll blame WordPress!

    Instead you really should really always recommend they use a WordPress hook and put it in their theme’s functions.php file. Here’s an example that adds vCard support:

    add_filter(‘upload_mimes’,'add_vcard_upload_support’));
    function add_vcard_upload_support($mimes) {
    $mimes['vcf|vcard'] = ‘text/x-vcard’;
    return $mimes;

    Hopefully you can update your post so and remove the recommendation to modify WordPress core to make sure nobody decides to do so in the future?

    Hope this helps.

    -Mike

  11. Darren Terhune
    06. Sep, 2010 at 7:14 pm #

    @Mike thanks for the suggestion… I think when I wrote this WordPress was at about version 1.0 so things have changed since then.

Trackbacks/Pingbacks

  1. Temple University Neural Instrumentation Lab » Wordpress Notes - 23. Jan, 2008

    [...] http://headfirstproductions.ca/blog/wordpress-file-type-upload-error-security-fix/ [...]

  2. Modifying file upload settings for WordPress — Andy Sylvester’s Web - 26. May, 2008

    [...] was “file type does not meet security guidelines”). After some searching, I found this article describing how to fix this problem (modifying wp-includes/functions.php to add ’sitx’ [...]

  3. Cambiar tipos de archivo que se pueden subir | Ayuda WordPress - 16. Mar, 2010

    [...] Option filters (Codex) | Chris Meller | Head first productions ?Te gust? este post? [...]

  4. Alterar os tipos de arquivo podem ser inseridos | Ajuda Wordpress em Portugu - 21. Mar, 2010

    [...] Fontes: Op??o de filtros (Codex) | Chris Meller | Head First Productions [...]

  5. MEMFILL or Modern Cabinet of Curiosities – Wordpress, MIME types, security guidelines and underscores in my filenames - 03. Nov, 2010

    [...] that the top 10 solutions returned by Google search are fucking horrible. Apparently, people prefer hacking at the core than extending and whoring hooking WordPress how Zeus intended [...]