post icon

WordPress File Upload Error Security Fix

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',

13 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.

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ês - 21. Mar, 2010

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