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 throughwp_check_filetype_and_ext
hook to allow validation of additional file types.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: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 afunction called get_allowed_mime_types.
I added
'java'
to the line that had'txt|asc|c|cc|h'
. Now the fileupload is working fine for
.java
files.