I am trying to upload java files to my WordPress blog but it does not let me upload any files with .java
extension.
I get this error:
“.java” has failed to upload due to an error
File type does not meet security guidelines. Try another.
How do I add .java
extension so that it allows me to upload java source code?
I am using WordPress version 3.0.4.
2 Answers
Use filter ‘upload_mimes’.
<?php
add_filter('upload_mimes','add_java_files');
function add_java_files($mimes)
{
// Add file extension 'extension' with mime type 'mime/type'
$mimes['java'] = 'text/x-java-source';
return $mimes;
}