CodeIgniter v4.5 API

FileCollection
in package

Class FileCollection

Provides easy access to uploaded files for a request.

Tags
see
FileCollectionTest

Table of Contents

Properties

$files  : array<string|int, mixed>|null
An array of UploadedFile instances for any files uploaded as part of this request.

Methods

all()  : array<string|int, mixed>|null
Returns an array of all uploaded files that were found.
getFile()  : UploadedFile|null
Attempts to get a single file from the collection of uploaded files.
getFileMultiple()  : array<int, UploadedFile>|null
Verify if a file exist in the collection of uploaded files and is have been uploaded with multiple option.
hasFile()  : bool
Checks whether an uploaded file with name $fileID exists in this request.
createFileObject()  : array<int, UploadedFile>|UploadedFile
Given a file array, will create UploadedFile instances. Will loop over an array and create objects for each.
fixFilesArray()  : array<string|int, mixed>
Reformats the odd $_FILES array into something much more like we would expect, with each object having its own array.
getValueDotNotationSyntax()  : array<int, UploadedFile>|UploadedFile|null
Navigate through an array looking for a particular index
populateFiles()  : void
Taking information from the $_FILES array, it creates an instance of UploadedFile for each one, saving the results to this->files.

Properties

$files

An array of UploadedFile instances for any files uploaded as part of this request.

protected array<string|int, mixed>|null $files

Populated the first time either files(), file(), or hasFile() is called.

Methods

all()

Returns an array of all uploaded files that were found.

public all() : array<string|int, mixed>|null

Each element in the array will be an instance of UploadedFile. The key of each element will be the client filename.

Return values
array<string|int, mixed>|null

getFile()

Attempts to get a single file from the collection of uploaded files.

public getFile(string $name) : UploadedFile|null
Parameters
$name : string
Return values
UploadedFile|null

getFileMultiple()

Verify if a file exist in the collection of uploaded files and is have been uploaded with multiple option.

public getFileMultiple(string $name) : array<int, UploadedFile>|null
Parameters
$name : string
Return values
array<int, UploadedFile>|null

hasFile()

Checks whether an uploaded file with name $fileID exists in this request.

public hasFile(string $fileID) : bool
Parameters
$fileID : string

The name of the uploaded file (from the input)

Return values
bool

createFileObject()

Given a file array, will create UploadedFile instances. Will loop over an array and create objects for each.

protected createFileObject(array<string|int, mixed> $array) : array<int, UploadedFile>|UploadedFile
Parameters
$array : array<string|int, mixed>
Return values
array<int, UploadedFile>|UploadedFile

fixFilesArray()

Reformats the odd $_FILES array into something much more like we would expect, with each object having its own array.

protected fixFilesArray(array<string|int, mixed> $data) : array<string|int, mixed>

Thanks to Jack Sleight on the PHP Manual page for the basis of this method.

Parameters
$data : array<string|int, mixed>
Tags
see
http://php.net/manual/en/reserved.variables.files.php#118294
Return values
array<string|int, mixed>

getValueDotNotationSyntax()

Navigate through an array looking for a particular index

protected getValueDotNotationSyntax(array<string|int, mixed> $index, array<string|int, mixed> $value) : array<int, UploadedFile>|UploadedFile|null
Parameters
$index : array<string|int, mixed>

The index sequence we are navigating down

$value : array<string|int, mixed>

The portion of the array to process

Return values
array<int, UploadedFile>|UploadedFile|null

populateFiles()

Taking information from the $_FILES array, it creates an instance of UploadedFile for each one, saving the results to this->files.

protected populateFiles() : void

Called by files(), file(), and hasFile()


        
On this page

Search results