wp_check_filetype_and_ext WordPress Filter Hook

The wp_check_filetype_and_ext hook is used to check the file type and extension of a given file. This hook is typically used when validating and sanitizing uploaded files.

apply_filters( 'wp_check_filetype_and_ext', array $wp_check_filetype_and_ext, string $file, string $filename, string[] $mimes, string|false $real_mime ) #

Filters the “real” file type of the given file.


Parameters

$wp_check_filetype_and_ext

(array)Values for the extension, mime type, and corrected filename.

  • 'ext'
    (string|false) File extension, or false if the file doesn't match a mime type.
  • 'type'
    (string|false) File mime type, or false if the file doesn't match a mime type.
  • 'proper_filename'
    (string|false) File name with its correct extension, or false if it cannot be determined.

$file

(string)Full path to the file.

$filename

(string)The name of the file (may differ from $file due to $file being in a tmp directory).

$mimes

(string[])Array of mime types keyed by their file extension regex.

$real_mime

(string|false)The actual mime type or false if the type cannot be determined.


Top ↑

Source

File: wp-includes/functions.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.1.0The $real_mime parameter was added.
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More