CoolCMS API

UploadLimit
in package

FinalYes

Computes the effective file upload limit: the smallest of the application limit and the PHP limits.

PHP limits are upload_max_filesize and post_max_size. PHP rejects a file above them before the application check runs, so a larger application limit would be a false promise.

Table of Contents

Methods

effectiveMaxFileSize()  : int
Returns `min(application limit, upload_max_filesize, post_max_size)`.
formatBytes()  : string
Formats bytes for messages (`2 MB`, `512 kB`).
parseIniSize()  : int
Converts a php.ini shorthand (`2M`, `512K`, `1G`, a bare number) to bytes; an empty or invalid value gives 0.

Methods

effectiveMaxFileSize()

Returns `min(application limit, upload_max_filesize, post_max_size)`.

public static effectiveMaxFileSize(int $appLimit[, string|false|null $uploadMaxFilesize = null ][, string|false|null $postMaxSize = null ]) : int

A PHP limit of 0 (and -1 for post_max_size) means unlimited and is left out of the minimum.

Parameters
$appLimit : int
$uploadMaxFilesize : string|false|null = null
$postMaxSize : string|false|null = null
Return values
int

formatBytes()

Formats bytes for messages (`2 MB`, `512 kB`).

public static formatBytes(int $bytes) : string
Parameters
$bytes : int
Return values
string

parseIniSize()

Converts a php.ini shorthand (`2M`, `512K`, `1G`, a bare number) to bytes; an empty or invalid value gives 0.

public static parseIniSize(string|false|null $value) : int
Parameters
$value : string|false|null
Return values
int
On this page

Search results