Documentation

Upload
in package

Upload helper class for working with the global $_FILES array and Validation library.

This is old Kohana cruft

Table of Contents

Methods

required()  : bool
Tests if input data has valid upload data.
save()  : string|false
Save an uploaded file to a new location.
size()  : bool
Validation rule to test if an uploaded file is allowed by file size.
type()  : bool
Validation rule to test if an uploaded file is allowed by extension.
valid()  : bool
Tests if input data is valid file type, even if no upload is present.

Methods

required()

Tests if input data has valid upload data.

public static required(array<string|int, mixed> $file) : bool
Parameters
$file : array<string|int, mixed>

$_FILES item

Return values
bool

save()

Save an uploaded file to a new location.

public static save(mixed $file[, string|null $filename = null ][, string|null $directory = null ][, int $chmod = 0644 ]) : string|false
Parameters
$file : mixed

name of $_FILE input or array of upload data

$filename : string|null = null

new filename

$directory : string|null = null

new directory

$chmod : int = 0644

chmod mask

Return values
string|false —

full path to new file or false on failure

size()

Validation rule to test if an uploaded file is allowed by file size.

public static size(array<string|int, mixed> $file, array<string|int, mixed> $size) : bool

File sizes are defined as: SB, where S is the size (1, 15, 300, etc) and B is the byte modifier: (B)ytes, (K)ilobytes, (M)egabytes, (G)igabytes. Eg: to limit the size to 1MB or less, you would use "1M".

Parameters
$file : array<string|int, mixed>

$_FILES item

$size : array<string|int, mixed>

maximum file size

Return values
bool

type()

Validation rule to test if an uploaded file is allowed by extension.

public static type(array<string|int, mixed> $file, array<string|int, mixed> $allowed_types) : bool
Parameters
$file : array<string|int, mixed>

$_FILES item

$allowed_types : array<string|int, mixed>

allowed file extensions

Return values
bool

valid()

Tests if input data is valid file type, even if no upload is present.

public static valid(array<string|int, mixed> $file) : bool
Parameters
$file : array<string|int, mixed>

$_FILES item

Return values
bool
On this page

Search results