upload_is_file_too_big() WordPress Function

The upload_is_file_too_big() function is used to check whether a given file is too large to be uploaded to WordPress. This is useful for preventing users from uploading excessively large files which could cause performance issues on your site.

upload_is_file_too_big( array $upload ) #

Checks whether an upload is too big.


Parameters

$upload

(array)(Required)


Top ↑

Return

(string|array) If the upload is under the size limit, $upload is returned. Otherwise returns an error message.


Top ↑

Source

File: wp-includes/ms-functions.php

function upload_is_file_too_big( $upload ) {
	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
		return $upload;
	}

	if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
		/* translators: %s: Maximum allowed file size in kilobytes. */
		return sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
	}

	return $upload;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)Introduced.

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