Class FormData
Provides an interface for building multipart/form-encoded message bodies.
Used by Http\Client to upload POST/PUT data and files.
Property Summary
-
$_boundary protected
string
Boundary marker.
-
$_parts protected
array
The parts in the form data.
Method Summary
-
__toString() public
Converts the FormData and its parts into a string suitable for use in an HTTP request.
-
add() public
Add a new part to the data.
-
addFile() public
Add either a file reference (string starting with @) or a file handle.
-
addMany() public
Add multiple parts at once.
-
addRecursive() public
Recursively add data.
-
boundary() public
Get the boundary marker
-
count() public
Returns the count of parts inside this object.
-
newPart() public
Method for creating new instances of Part
Method Detail
__toString() ¶ public
__toString(): string
Converts the FormData and its parts into a string suitable for use in an HTTP request.
Returns
string
add() ¶ public
add(stringCake\Network\Http\FormData $name, mixed $value = null): $this
Add a new part to the data.
The value for a part can be a string, array, int, float, filehandle, or object implementing __toString()
If the $value is an array, multiple parts will be added. Files will be read from their current position and saved in memory.
Parameters
-
stringCake\Network\Http\FormData
$name The name of the part to add, or the part data object.
-
mixed
$value optional The value for the part.
Returns
$this
addFile() ¶ public
addFile(string $name, mixed $value): Cake\Network\Http\FormData\Part
Add either a file reference (string starting with @) or a file handle.
Parameters
-
string
$name The name to use.
-
mixed
$value Either a string filename, or a filehandle.
Returns
Cake\Network\Http\FormData\Part
addMany() ¶ public
addMany(array $data): $this
Add multiple parts at once.
Iterates the parameter and adds all the key/values.
Parameters
-
array
$data Array of data to add.
Returns
$this
addRecursive() ¶ public
addRecursive(string $name, mixed $value): void
Recursively add data.
Parameters
-
string
$name The name to use.
-
mixed
$value The value to add.
Returns
void
newPart() ¶ public
newPart(string $name, string $value): Cake\Network\Http\FormData\Part
Method for creating new instances of Part
Parameters
-
string
$name The name of the part.
-
string
$value The value to add.
Returns
Cake\Network\Http\FormData\Part