public function writeFile($filename)
    {
        $file = $this->getAttribute('file');
        if (empty($file) && !$this->getIsNewRecord()) {
            $file = $this->refreshFile();
        }

        if (empty($file)) {
            throw new InvalidParamException('There is no file associated with this object.');
        } elseif ($file instanceof Download) {
            return ($file->toFile($filename) == $file->getSize());
        } elseif ($file instanceof UploadedFile) {
            return copy($file->tempName, $filename);
        } elseif (is_string($file)) {
            if (file_exists($file)) {
                return copy($file, $filename);
            }
            throw new InvalidParamException("File '{$file}' does not exist.");
        }

        throw new InvalidParamException('Unsupported type of "file" attribute.');
    }
public function writeFile($filename)
    {
        $file = $this->getAttribute('file');
        if (empty($file) && !$this->getIsNewRecord()) {
            $file = $this->refreshFile();
        }

        if (empty($file)) {
            throw new InvalidParamException('There is no file associated with this object.');
        } elseif ($file instanceof Download) {
            return ($file->toFile($filename) == $file->getSize());
        } elseif ($file instanceof UploadedFile) {
            return copy($file->tempName, $filename);
        } elseif (is_string($file)) {
            if (file_exists($file)) {
                return copy($file, $filename);
            }
            throw new InvalidParamException("File '{$file}' does not exist.");
        }

        throw new InvalidParamException('Unsupported type of "file" attribute.');
    }
public function writeFile ( $ filename ) { $ file = $ this -> getAttribute ( 'file' ) ; if ( empty ( $ file ) && ! $ this -> getIsNewRecord ( ) ) { $ file = $ this -> refreshFile ( ) ; } if ( empty ( $ file ) ) { throw new InvalidParamException ( 'There is no file associated with this object.' ) ; } elseif ( $ file instanceof Download ) { return ( $ file -> toFile ( $ filename ) == $ file -> getSize ( ) ) ; } elseif ( $ file instanceof UploadedFile ) { return copy ( $ file -> tempName , $ filename ) ; } elseif ( is_string ( $ file ) ) { if ( file_exists ( $ file ) ) { return copy ( $ file , $ filename ) ; } throw new InvalidParamException ( "File '{$file}' does not exist." ) ; } throw new InvalidParamException ( 'Unsupported type of "file" attribute.' ) ; }
Writes the the internal file content into the given filename.
@param string $filename full filename to be written.
@return bool whether the operation was successful.
@throws \yii\base\InvalidParamException on invalid file attribute value.
Writes the the internal file content into the given filename .