DiscordPHP Documentation

Multipart
in package

Builds a multipart request.

Tags
since
5.1.0
author

David Cole david.cole1340@gmail.com

Table of Contents

BOUNDARY  = '----DiscordPHPSendFileBoundary'
The boundary seperating multipart sections.
$boundary  : string
Field boundary.
$fields  : array<string|int, mixed>
Fields part of the request.
__construct()  : mixed
Multipart constructor.
__toString()  : string
Converts the multipart request to string.
add()  : $this
Adds a field to the request.
getContentType()  : string
Gets the content type for the multipart request.
getHeaders()  : array<string|int, mixed>
Gets the headers for the given request.

Constants

BOUNDARY

The boundary seperating multipart sections.

private mixed BOUNDARY = '----DiscordPHPSendFileBoundary'

Properties

$boundary

Field boundary.

protected string $boundary

$fields

Fields part of the request.

protected array<string|int, mixed> $fields = []

Methods

__construct()

Multipart constructor.

public __construct([array<string|int, mixed> $fields = [] ][, string $boundary = self::BOUNDARY ]) : mixed
Parameters
$fields : array<string|int, mixed> = []
$boundary : string = self::BOUNDARY
Return values
mixed

__toString()

Converts the multipart request to string.

public __toString() : string
Return values
string

add()

Adds a field to the request.

public add(mixed ...$fields) : $this
$field = [
    'name' => 'Field name',
    'content' => 'Field content',

     // Optional
    'filename' => 'File name',
    'headers' => [
        // ...
    ],
];
Parameters
$fields : mixed
Return values
$this

getContentType()

Gets the content type for the multipart request.

public getContentType() : string
Return values
string

getHeaders()

Gets the headers for the given request.

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results