On this page
Class FormData
Provides an interface for building multipart/form-encoded message bodies.
Used by Http\Client to upload POST/PUT data and files.
- Cake\Http\Client\FormData implements Countable
 
Properties summary
- 
    
$_boundaryprotectedBoundary marker.string - 
    
$_hasComplexPartprotectedWhether or not this formdata object has a complex part.boolean - 
    
$_hasFileprotectedWhether or not this formdata object has attached files.boolean - 
    
$_partsprotectedThe parts in the form data.array 
Method Summary
- 
    __toString() public
Converts the FormData and its parts into a string suitable for use in an HTTP request.
 - 
    add() publicAdd a new part to the data.
 - 
    addFile() public
Add 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() public
Check whether or not the current payload has any files.
 - 
    isMultipart() public
Check whether or not the current payload is multipart.
 - 
    newPart() publicMethod for creating new instances of Part
 
Method Detail
__toString()source public
__toString( )
   Converts the FormData and its parts into a string suitable for use in an HTTP request.
Returns
stringadd()source public
add( string|Cake\Http\Client\FormData $name , mixed $value null )
   Add 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\Http\Client\FormData$name - 
     
The name of the part to add, or the part data object.
 - 
     mixed 
$valueoptional null - The value for the part.
 
Returns
$this
addFile()source public
addFile( string $name , mixed $value )
   Add 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\Http\Client\FormDataPartaddMany()source public
addMany( array $data )
   Add multiple parts at once.
Iterates the parameter and adds all the key/values.
Parameters
- 
     array 
$data - Array of data to add.
 
Returns
$this
addRecursive()source public
addRecursive( string $name , mixed $value )
   Recursively add data.
Parameters
- 
     string 
$name - The name to use.
 - 
     mixed 
$value - The value to add.
 
contentType()source public
contentType( )
   Get 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
stringcount()source public
count( )
   Returns the count of parts inside this object.
Returns
integerImplementation of
Countable::count()
  hasFile()source public
hasFile( )
   Check whether or not the current payload has any files.
Returns
booleanWhether or not there is a file in this payload.
isMultipart()source public
isMultipart( )
   Check 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
booleanWhether or not the payload is multipart.
newPart()source public
newPart( string $name , string $value )
   Method for creating new instances of Part
Parameters
- 
     string 
$name - The name of the part.
 - 
     string 
$value - The value to add.
 
Returns
Cake\Http\Client\FormDataPartProperties detail
$_hasComplexPartsource
protected boolean
Whether or not this formdata object has a complex part.
false
   © 2005–2017 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.3/class-Cake.Http.Client.FormData.html