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.
Property Summary
-
$_contentId protected
stringThe contentId for the part
-
$_disposition protected
stringDisposition to send
-
$_filename protected
stringFilename to send if using files.
-
$_name protected
stringName of the value.
-
$_transferEncoding protected
stringThe encoding used in this part.
-
$_type protected
stringContent type to use
-
$_value protected
stringValue to send.
Method Summary
-
__construct() public
Constructor
-
__toString() public
Convert the part into a string.
-
contentId() public
Get/set the contentId for a part.
-
disposition() public
Get/set the disposition type
-
filename() public
Get/set the filename.
-
name() public
Get the part name.
-
transferEncoding() public
Set the transfer-encoding for multipart.
-
type() public
Get/set the content type.
-
value() public
Get the value.
Method Detail
__construct() ¶ public
__construct(string $name, string $value, string $disposition = 'form-data')
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.
__toString() ¶ public
__toString(): string
Convert the part into a string.
Creates a string suitable for use in HTTP requests.
Returns
stringcontentId() ¶ public
contentId(null|string $id = null): string|null
Get/set the contentId for a part.
Parameters
-
null|string$id optional The content id.
Returns
string|nulldisposition() ¶ public
disposition(null|string $disposition = null): string|null
Get/set the disposition type
By passing in false you can disable the disposition
header from being added.
Parameters
-
null|string$disposition optional Use null to get/string to set.
Returns
string|nullfilename() ¶ public
filename(null|string $filename = null): string|null
Get/set the filename.
Setting the filename to false will exclude it from the
generated output.
Parameters
-
null|string$filename optional Use null to get/string to set.
Returns
string|nulltransferEncoding() ¶ public
transferEncoding(null|string $type): string|null
Set the transfer-encoding for multipart.
Useful when content bodies are in encodings like base64.
Parameters
-
null|string$type The type of encoding the value has.
Returns
string|nulltype() ¶ public
type(null|string $type): string|null
Get/set the content type.
Parameters
-
null|string$type Use null to get/string to set.
Returns
string|null