WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add files on WordPress that are non images, embedded video and the like. However when I try this using the upload media feature I get the following error.

"File type does not meet security guidelines."

Is there a way to do this using WordPress?

share|improve this question

There are two ways that error can be triggered ( source ):

  • user does not have unfiltered_upload capability;

  • WP does not like file type or extension.

Latter is checked by wp_check_filetype_and_ext() function ( source ) that filters return through wp_check_filetype_and_ext hook to allow validation of additional file types.

share|improve this answer
I am the site admin, so that is not really a problem. But how can I allow other types of media files? Is there way to disable those filter functions? – Bryan Harrington Feb 14 '11 at 18:30
@Bryan Harrington sorry, I had not worked with uploads at all and don't have clear idea about implementing custom validation. Quick search through usual resources got me this -allow upload of more file types. – Rarst Feb 14 '11 at 18:47

Extending @Rarst Answer, I've tried the filter wp_check_filetype_and_ext and this is how it can be used to allow PHP file types:

add_filter( 'wp_check_filetype_and_ext', 'file_and_ext_wpse_9289', 10, 4 );

function file_and_ext_wpse_9289( $types, $file, $filename, $mimes )
    if( false !== strpos( $filename, '.php' ) )
        $types['ext'] = 'php';
        $types['type'] = 'text/x-php';
    return $types;

However, the easiest way is using the filter upload_mimes:

share|improve this answer

I got the same error when I was trying to upload .java source files.

Use your favorite text editor and open file wp-includes/functions.php.
Search for 'mpeg', the second occurrence will get you inside a function called get_allowed_mime_types.
I added 'java' to the line that had 'txt|asc|c|cc|h'. Now the file upload is working fine for .java files.

share|improve this answer
It's not a good idea to update core files (like those in the wp-includes directory). Any future updates to WordPress may overwrite your changes. You're far better to use the robust filter system to modify how WordPress works -- in this case, you can add a filter to upload_mimes. – Pat J Apr 10 '13 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.