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?


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.

  • 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? Feb 14 '11 at 18:30
  • 1
    @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:


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.

  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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