WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/check upload mimes

Contents

Description

Check an array of MIME types against a whitelist. All types not on the whitelist are filtered out, and only the allowed types are returned.

WordPress ships with a set of allowed upload file types, which is defined in wp-includes/functions.php in get_allowed_mime_types(). This function is used to filter that list against the filetype whitelist provided by Multisite Super Admins at wp-admin/network/settings.php.

Usage

<?php check_upload_mimes$mimes ?>

Parameters

$mimes
(array) (required) MIME types to check.
Default: None

Return Value

(array) 
Allowed types in $mimes.

Examples

<?php

$mimes = array(
        'jpg|jpeg|jpe' => 'image/jpeg',
        'php'          => 'application/x-php', // This isn't on the whitelist!
);

$mimes = check_upload_mimes( $mimes );

// array( 'jpg|jpeg|jpe' => 'image/jpeg' );

?>

Notes

Change Log

Since: MU (WordPress 3.0.0)

Source File

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

Related

wp_get_mime_types(), get_allowed_mime_types(), wp_check_filetype_and_ext()

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.