public function toFile($filename)
    {
        $filename = Yii::getAlias($filename);
        FileHelper::createDirectory(dirname($filename));
        return $this->toStream(fopen($filename, 'w+'));
    }
public function toFile($filename)
    {
        $filename = Yii::getAlias($filename);
        FileHelper::createDirectory(dirname($filename));
        return $this->toStream(fopen($filename, 'w+'));
    }
public function toFile ( $ filename ) { $ filename = Yii :: getAlias ( $ filename ) ; FileHelper :: createDirectory ( dirname ( $ filename ) ) ; return $ this -> toStream ( fopen ( $ filename , 'w+' ) ) ; }
Saves download to the physical file.
@param string $filename name of the physical file.
@return int number of written bytes.
Saves download to the physical file .