public function EntityEnclosingRequest::addPostFiles

Add POST files to use in the upload

Parameters

array $files An array of POST fields => filenames where filename can be a string or PostFileInterface:

Return value

EntityEnclosingRequestInterface

Overrides EntityEnclosingRequestInterface::addPostFiles

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/EntityEnclosingRequest.php, line 263

Class

EntityEnclosingRequest
HTTP request that sends an entity-body in the request message (POST, PUT, PATCH, DELETE)

Namespace

Guzzle\Http\Message

Code

public function addPostFiles(array $files) {
  foreach ($files as $key => $file) {
    if ($file instanceof PostFileInterface) {
      $this
        ->addPostFile($file, null, null, false);
    }
    elseif (is_string($file)) {

      // Convert non-associative array keys into 'file'
      if (is_numeric($key)) {
        $key = 'file';
      }
      $this
        ->addPostFile($key, $file, null, false);
    }
    else {
      throw new RequestException('File must be a string or instance of PostFileInterface');
    }
  }
  return $this;
}