Class FormData
Provides an interface for building multipart/form-encoded message bodies.
Used by Http\Client to upload POST/PUT data and files.
Property Summary
- 
        $_boundary protectedstringBoundary marker. 
- 
        $_hasComplexPart protectedboolWhether or not this formdata object has a complex part. 
- 
        $_hasFile protectedboolWhether or not this formdata object has attached files. 
- 
        $_parts protectedarrayThe parts in the form data. 
Method Summary
- 
          __toString() publicConverts the FormData and its parts into a string suitable for use in an HTTP request. 
- 
          add() publicAdd a new part to the data. 
- 
          addFile() publicAdd either a file reference (string starting with @) or a file handle. 
- 
          addMany() publicAdd multiple parts at once. 
- 
          addRecursive() publicRecursively add data. 
- 
          boundary() publicGet the boundary marker 
- 
          contentType() publicGet the content type for this payload. 
- 
          count() publicReturns the count of parts inside this object. 
- 
          hasFile() publicCheck whether or not the current payload has any files. 
- 
          isMultipart() publicCheck whether or not the current payload is multipart. 
- 
          newPart() publicMethod for creating new instances of Part 
Method Detail
__toString() ¶ public
__toString(): stringConverts the FormData and its parts into a string suitable for use in an HTTP request.
Returns
stringadd() ¶ public
add(string|Cake\Network\Http\FormData $name, mixed $value = null): $thisAdd a new part to the data.
The value for a part can be a string, array, int, float, filehandle, or object implementing __toString()
If the $value is an array, multiple parts will be added. Files will be read from their current position and saved in memory.
Parameters
- 
                string|Cake\Network\Http\FormData$name
- The name of the part to add, or the part data object. 
- 
                mixed$value optional
- The value for the part. 
Returns
$thisaddFile() ¶ public
addFile(string $name, mixed $value): Cake\Network\Http\FormData\PartAdd either a file reference (string starting with @) or a file handle.
Parameters
- 
                string$name
- The name to use. 
- 
                mixed$value
- Either a string filename, or a filehandle. 
Returns
Cake\Network\Http\FormData\PartaddMany() ¶ public
addMany(array $data): $thisAdd multiple parts at once.
Iterates the parameter and adds all the key/values.
Parameters
- 
                array$data
- Array of data to add. 
Returns
$thisaddRecursive() ¶ public
addRecursive(string $name, mixed $value): voidRecursively add data.
Parameters
- 
                string$name
- The name to use. 
- 
                mixed$value
- The value to add. 
Returns
voidcontentType() ¶ public
contentType(): stringGet the content type for this payload.
If this object contains files, multipart/form-data will be used,
otherwise application/x-www-form-urlencoded will be used.
Returns
stringhasFile() ¶ public
hasFile(): boolCheck whether or not the current payload has any files.
Returns
boolWhether or not there is a file in this payload.
isMultipart() ¶ public
isMultipart(): boolCheck whether or not the current payload is multipart.
A payload will become multipart when you add files or use add() with a Part instance.
Returns
boolWhether or not the payload is multipart.
newPart() ¶ public
newPart(string $name, string $value): Cake\Network\Http\FormData\PartMethod for creating new instances of Part
Parameters
- 
                string$name
- The name of the part. 
- 
                string$value
- The value to add. 
Returns
Cake\Network\Http\FormData\Part