yii\httpclient\Request::addFile PHP Method

addFile() public method

Adds a file for upload as multi-part content.
See also: addContent()
public addFile ( string $name, string $fileName, array $options = [] )
$name string part (form input) name
$fileName string full name of the source file.
$options array content part options, valid options are: - fileName - string, base name of the uploading file, if not set it base name of the source file will be used. - mimeType - string, file mime type, if not set it will be determine automatically from source file.
    public function addFile($name, $fileName, $options = [])
    {
        $content = file_get_contents($fileName);
        if (!isset($options['mimeType'])) {
            $options['mimeType'] = FileHelper::getMimeType($fileName);
        }
        if (!isset($options['fileName'])) {
            $options['fileName'] = basename($fileName);
        }
        return $this->addContent($name, $content, $options);
    }