phasync
MultipartStream / __construct

Method

MultipartStream::__construct

Create the body from the fields.

Description#

public MultipartStream::__construct(
    array $fields,
    ?string $boundary = null
)

Parameters#

$fields array
Field name to value: a scalar, a Stringable, a stream resource, an SplFileInfo, or a nested array
$boundary ?string = null
The boundary string; random when null

Examples#

Example 1
$body = new MultipartStream(['name' => 'Frode', 'files' => [\fopen('a.txt', 'r'), \fopen('b.txt', 'r')]]);

See also#