Menu

Reference / Http

Part

finalclass
final class Part

One part of a streamed multipart/form-data body, read straight off the connection.

Get parts from Request::multipart(). Nothing is buffered beyond a single read and no temporary file is created. A part is readable only while it is the current one: once the loop moves on, read() answers ''. A part you stop reading is drained for you when the loop advances.

See also: Request, Server

Methods

read()Reads up to $max bytes of this part.
readAll()Reads the rest of this part into one string.

read()#source

function read(int $max): string

Reads up to $max bytes of this part.

Answers '' once the part's closing delimiter is reached, or when this part is no longer the current one. If the client cuts the connection mid-part, the remaining bytes are returned and then ''; there is no error signal in this mode.

Parameters

$max int
Largest number of bytes to return.

Returns

string โ€” The bytes, or an empty string at the end of the part.

readAll()#source

function readAll(): string

Reads the rest of this part into one string. The size is not capped; use read() for large files.

Returns

string โ€” The remaining bytes.

View source