Codex tools: Log in
Contents |
Attempts to determine the real file type of a file.
If unable to, the file name extension will be used to determine type.
If it's determined that the extension does not match the file's real type,
then the "proper_filename" value will be set with a proper filename and extension.
<?php
$validate = wp_check_filetype_and_ext( $file, $filename, $mimes );
if( $validate['proper_filename'] !== false )
$filename = $validate['proper_filename'];
?>
Currently this function only supports validating images known to getimagesize().
If using in a plugin/theme and you get an error about this function not being defined, you probably need to add require_once ABSPATH .'wp-admin/includes/file.php'; before the function gets called.
Since: 3.0.0
wp_check_filetype_and_ext() is located in wp-includes/functions.php