FLVファイルアップロードで「ファイルタイプがセキュリティガイドラインを満たしていません。」を解決

WordPress の記事投稿で FLVファイルのアップロードをしようとすると、 「ファイルタイプがセキュリティガイドラインを満たしていません。別のファイルタイプを試してください。」 とエラーメッセージが出たので調べてみました。

現在のバージョンは 「2.8.6」 。 以前に一度、 FLVファイルをアップロードしたことがあるのですが、その際はこのようなエラーは出ませんでした。(バージョン 2.5 or 2.6)

調べた結果、 wp-includes フォルダ内の functions.php ファイルを修正することで解決。

手順は以下。

2201行目付近の function wp_ext2type 。

function wp_ext2type( $ext ) {
	$ext2type = apply_filters('ext2type', array(
		'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b'
,'ogg','ram','wav','wma'),
		'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv'
,'ogm','qt','rm','vob','wmv', 'm4v'),
		'document' => array('doc','docx','pages','odt','rtf','pdf'),
		'spreadsheet' => array('xls','xlsx','numbers','ods'),
		'interactive' => array('ppt','pptx','key','odp','swf'),
		'text' => array('txt'),
		'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'),
		'code' => array('css','html','php','js'),
	));
	foreach ( $ext2type as $type => $exts )
		if ( in_array($ext, $exts) )
			return $type;
}

video の最後、 「, ‘m4v’」 のあとに、「,’flv’,'f4v’」 を追加。

function wp_ext2type( $ext ) {
	$ext2type = apply_filters('ext2type', array(
		'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b'
,'ogg','ram','wav','wma'),
		'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv'
,'ogm','qt','rm','vob','wmv','m4v','flv','f4v'),
		'document' => array('doc','docx','pages','odt','rtf','pdf'),
		'spreadsheet' => array('xls','xlsx','numbers','ods'),
		'interactive' => array('ppt','pptx','key','odp','swf'),
		'text' => array('txt'),
		'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'),
		'code' => array('css','html','php','js'),
	));
	foreach ( $ext2type as $type => $exts )
		if ( in_array($ext, $exts) )
			return $type;
}

もう一カ所、2253行目付近 function get_allowed_mime_types 。

function get_allowed_mime_types() {
	static $mimes = false;

	if ( !$mimes ) {
		// Accepted MIME types are set here as PCRE unless provided.
		$mimes = apply_filters( 'upload_mimes', array(
		'jpg|jpeg|jpe' => 'image/jpeg',
		'gif' => 'image/gif',
		'png' => 'image/png',
		'bmp' => 'image/bmp',
		'tif|tiff' => 'image/tiff',
		'ico' => 'image/x-icon',
		'asf|asx|wax|wmv|wmx' => 'video/asf',
		'avi' => 'video/avi',
		'divx' => 'video/divx',
		'mov|qt' => 'video/quicktime',
		'mpeg|mpg|mpe' => 'video/mpeg',
		'txt|c|cc|h' => 'text/plain',
		'rtx' => 'text/richtext',
		'css' => 'text/css',
		'htm|html' => 'text/html',
		'mp3|m4a' => 'audio/mpeg',
		'mp4|m4v' => 'video/mp4',
		'ra|ram' => 'audio/x-realaudio',
		'wav' => 'audio/wav',
		'ogg' => 'audio/ogg',
		'mid|midi' => 'audio/midi',
		'wma' => 'audio/wma',
		'rtf' => 'application/rtf',
		'js' => 'application/javascript',
		'pdf' => 'application/pdf',
		'doc|docx' => 'application/msword',
		'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
		'wri' => 'application/vnd.ms-write',
		'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
		'mdb' => 'application/vnd.ms-access',
		'mpp' => 'application/vnd.ms-project',
		'swf' => 'application/x-shockwave-flash',
		'class' => 'application/java',
		'tar' => 'application/x-tar',
		'zip' => 'application/zip',
		'gz|gzip' => 'application/x-gzip',
		'exe' => 'application/x-msdownload',
		// openoffice formats
		'odt' => 'application/vnd.oasis.opendocument.text',
		'odp' => 'application/vnd.oasis.opendocument.presentation',
		'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
		'odg' => 'application/vnd.oasis.opendocument.graphics',
		'odc' => 'application/vnd.oasis.opendocument.chart',
		'odb' => 'application/vnd.oasis.opendocument.database',
		'odf' => 'application/vnd.oasis.opendocument.formula',
		) );
	}

	return $mimes;
}

// Accepted MIME types are set here as PCRE unless provided.
$mimes = apply_filters( ‘upload_mimes’, array( の後ろに、
‘flv’ => ‘video/x-flv’,
‘f4v’ => ‘video/mp4′, を追加。

function get_allowed_mime_types() {
	static $mimes = false;

	if ( !$mimes ) {
		// Accepted MIME types are set here as PCRE unless provided.
		$mimes = apply_filters( 'upload_mimes', array(
		'flv' => 'video/x-flv',
		'f4v' => 'video/mp4',
		'jpg|jpeg|jpe' => 'image/jpeg',
		'gif' => 'image/gif',
		'png' => 'image/png',
		'bmp' => 'image/bmp',
		'tif|tiff' => 'image/tiff',
		'ico' => 'image/x-icon',
		'asf|asx|wax|wmv|wmx' => 'video/asf',
		'avi' => 'video/avi',
		'divx' => 'video/divx',
		'mov|qt' => 'video/quicktime',
		'mpeg|mpg|mpe' => 'video/mpeg',
		'txt|c|cc|h' => 'text/plain',
		'rtx' => 'text/richtext',
		'css' => 'text/css',
		'htm|html' => 'text/html',
		'mp3|m4a' => 'audio/mpeg',
		'mp4|m4v' => 'video/mp4',
		'ra|ram' => 'audio/x-realaudio',
		'wav' => 'audio/wav',
		'ogg' => 'audio/ogg',
		'mid|midi' => 'audio/midi',
		'wma' => 'audio/wma',
		'rtf' => 'application/rtf',
		'js' => 'application/javascript',
		'pdf' => 'application/pdf',
		'doc|docx' => 'application/msword',
		'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
		'wri' => 'application/vnd.ms-write',
		'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
		'mdb' => 'application/vnd.ms-access',
		'mpp' => 'application/vnd.ms-project',
		'swf' => 'application/x-shockwave-flash',
		'class' => 'application/java',
		'tar' => 'application/x-tar',
		'zip' => 'application/zip',
		'gz|gzip' => 'application/x-gzip',
		'exe' => 'application/x-msdownload',
		// openoffice formats
		'odt' => 'application/vnd.oasis.opendocument.text',
		'odp' => 'application/vnd.oasis.opendocument.presentation',
		'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
		'odg' => 'application/vnd.oasis.opendocument.graphics',
		'odc' => 'application/vnd.oasis.opendocument.chart',
		'odb' => 'application/vnd.oasis.opendocument.database',
		'odf' => 'application/vnd.oasis.opendocument.formula',
		) );
	}

	return $mimes;
}

以上で FLV と F4V ファイルのアップロードが可能になります。

これは WordPress 2.8.6 での対処法です。 これ以外のバージョンは定かではありません。

今回は以下のサイト様を参考にさせて頂きました m(_ _)m。

参考サイト
2BLOG
WordPressで.flvの拡張子を登録しないとエラーが表示される
  • 人気ブログランキング
  • FC2ブログランキング
コメント/トラックバック (1件のコメント)
トラックバック用URL:

この記事のコメント・トラックバックRSS

  1. [...] これでアップロード出来る様になりました。 下のサイトを参考にさせて頂きました。 おぼえがき [...]

コメントをどうぞ

使用できるXHTMLタグ: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>