Class FormDataPart

Contains the data and behavior for a single part in a Multipart FormData request body.

Added to Cake\Http\Client\FormData when sending data to a remote server.

Namespace: Cake\Http\Client

Properties summary

  • $_charset protected
    string|null

    The charset attribute for the Content-Disposition header fields

  • $_contentId protected
    string

    The contentId for the part

  • $_disposition protected
    string

    Disposition to send

  • $_filename protected
    string

    Filename to send if using files.

  • $_name protected
    string

    Name of the value.

  • $_transferEncoding protected
    string

    The encoding used in this part.

  • $_type protected
    string

    Content type to use

  • $_value protected
    string

    Value to send.

Method Summary

Method Detail

__construct() public

__construct(mixed $name, mixed $value, mixed $disposition, mixed $charset)

Constructor

Parameters

string $name

The name of the data.

string $value

The value of the data.

string $disposition optional

The type of disposition to use, defaults to form-data.

string|null $charset optional

The charset of the data.

__toString() public

__toString()

Convert the part into a string.

Creates a string suitable for use in HTTP requests.

Returns

string

_headerParameterToString() protected

_headerParameterToString(mixed $name, mixed $value)

Get the string for the header parameter.

If the value contains non-ASCII letters an additional header indicating the charset encoding will be set.

Parameters

string $name

The name of the header parameter

string $value

The value of the header parameter

Returns

string

contentId() public

contentId(mixed $id)

Get/set the contentId for a part.

Parameters

string|null $id optional

The content id.

Returns

string|null

disposition() public

disposition(mixed $disposition)

Get/set the disposition type

By passing in false you can disable the disposition header from being added.

Parameters

string|null $disposition optional

Use null to get/string to set.

Returns

string|null

filename() public

filename(mixed $filename)

Get/set the filename.

Setting the filename to false will exclude it from the generated output.

Parameters

string|null $filename optional

Use null to get/string to set.

Returns

string|null

name() public

name()

Get the part name.

Returns

string

transferEncoding() public

transferEncoding(mixed $type)

Set the transfer-encoding for multipart.

Useful when content bodies are in encodings like base64.

Parameters

string|null $type

The type of encoding the value has.

Returns

string|null

type() public

type(mixed $type)

Get/set the content type.

Parameters

string|null $type

Use null to get/string to set.

Returns

string|null

value() public

value()

Get the value.

Returns

string

Property Detail

$_charset protected

The charset attribute for the Content-Disposition header fields

Type

string|null

$_contentId protected

The contentId for the part

Type

string

$_disposition protected

Disposition to send

Type

string

$_filename protected

Filename to send if using files.

Type

string

$_name protected

Name of the value.

Type

string

$_transferEncoding protected

The encoding used in this part.

Type

string

$_type protected

Content type to use

Type

string

$_value protected

Value to send.

Type

string

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.9/class-Cake.Http.Client.FormDataPart.html