WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp check filetype

Contents

Description

Retrieve the file type from the file name.

You can optionally define the mime array, if needed.

Usage

<?php wp_check_filetype$filename$mimes ?>

Parameters

$filename
(string) (required) File name or path.
Default: None
$mimes
(array) (optional) Key is the file extension with value as the mime type.
Default: null

Return Values

(array) 
Values with extension first and mime type.
  • ['ext'] - Extension (eg 'jpg')
  • ['type'] - Mime Type (eg 'image/jpeg')

Examples

<?php
$filetype = wp_check_filetype('image.jpg');
echo $filetype['ext']; // will output jpg
?>

Notes

Change Log

Since: 2.0.4

Source File

wp_check_filetype() is located in wp-includes/functions.php.

Related

wp_check_filetype_and_ext()

See also index of Function Reference and index of Template Tags.