Saves download to the physical file.
@param string $filename name of the physical file.
@return int number of written bytes.
429108
public function toFile($filename)
    {
        $filename = Yii::getAlias($filename);
        FileHelper::createDirectory(dirname($filename));
        return $this->toStream(fopen($filename, 'w+'));
    }
54055
public function save($filename)
    {
        $json = [];
        foreach ($this as $cookie) {
            if ($cookie->getExpires() && !$cookie->getDiscard()) {
                $json[] = $cookie->toArray();
            }
        }

        if (false === file_put_contents($filename, json_encode($json))) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException("Unable to save file {$filename}");
            // @codeCoverageIgnoreEnd
        }
    }
967222
private function _addFile($filename)
		{
			if (true === $this->_enabled) {
				if (File::exists($filename)) {
					if (is_dir($filename)) {
						return $this->_zip->addEmptyDir($filename);
					} else {
						return $this->_zip->addFile($filename);
					}
				}
			}

			return false;
		}
299894
public function toFile( $fileName ){
		$css	= FS_File_CSS_Converter::convertSheetToString( $this->sheet );
		return FS_File_Writer::save( $fileName, $css );
	}
1028445
public function save($filename, $content)
    {
        $this->logs[] = $content;
        $this->storage->save($filename, $content);

        return $this;
    }
247949
public function download($filename = '')
    {
        $filename = $this->formatFilename($filename);
        if ($this->content) {
            $this->printHeader();
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            echo $this->content;
        } elseif ($this->path) {
            $fsize = filesize($this->path);
            $this->printHeader($fsize);
            header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
            ob_clean();
            readfile($this->path);
        }
    }
611438
public function as_download( $filename = null ) 
	{
		if ( is_null( $filename ) ) 
		{
			$filename = 'file.'.CCStr::suffix( $this->header( 'Content-Type' ), '/' );
		}

		$this->header( 'Content-Description', 'File Transfer' );
		$this->header( 'Content-Disposition', 'attachment; filename='.$filename );
		$this->header( 'Content-Transfer-Encoding', 'binary' );
		$this->header( 'Expires', '0' );
		$this->header( 'Cache-Control', 'must-revalidate' );
		$this->header( 'Pragma', 'public' );
		$this->header( 'Content-Length', strlen( $this->body() ) );

		return $this;
	}
213190
static public function touch($filename)
	{
	    $ret = true;
	    if ($filename && !file_exists($filename)) {
	        $ret = static::write($filename, '');
	    }
	    return $ret;
	}
962129
public function deleteFileByName($filename)
    {
        $destinationPath = $this->getDestinationPath();
        $destination = $destinationPath . '/' . $filename;

        if (file_exists($destination)) {
            $files = $this->getFiles();
            foreach ($files as $key => $file) {
                if ($file->file == $filename) {
                    unlink($destination);
                    unset($files[$key]);
                }
            }

            $files = array_values($files);
            $this->repository->files = $files;
            $this->save();
        }
    }
768253
public function save( $fileName = false )
	{
		if( !$fileName )
		{
			if( !$this->fileName )
				throw new Exception( "No TGZ file name for saving given." );
			$fileName = $this->fileName;
		}
		$this->generateTar();												// Encode processed files into TAR file format
		$f = new FS_File_Arc_Gzip( $fileName );
		$f->writeString( $this->content);
		return true;
	}
343403
public function store($filename, $filext=DEFAULTS::EXTENSION)
    {	
      return FileHandler::save($filename, $this->data);
    }
1013133
public function download($filename)
    {
        $basename = pathinfo($filename, PATHINFO_BASENAME);
        $extension = pathinfo($basename, PATHINFO_EXTENSION);

        // Cabeçalhos para MimeType
        switch(Str::lower($extension))
        {
            case 'csv':
                header('Content-Type: text/csv');
                break;

            case 'html':
                header('Content-Type: text/html');
                break;

            case 'ods':
                header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
                break;

            case 'pdf':
                header('Content-Type: application/pdf');
                break;

            case 'xls':
                header('Content-Type: application/vnd.ms-excel');
                break;

            case 'xlsx':
                header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                break;
        }

        // Cabeçalhos para Download
        header('Content-Disposition: attachment;filename="'.$basename.'"');
        header('Cache-Control: max-age=0');
        header('Cache-Control: max-age=1'); //IE 9

        // Para evitar cache no IE
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Data no passado
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // Sempre modificado
        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
        header('Pragma: public'); // HTTP/1.0

        $this->save('php://output');
        exit;
    }
446343
public function download($filename = null)
    {
        $filename = $filename ?: date('Y-m-d_His') . '.csv';
        $this->writer->output($filename);
    }
102329
public static function save( $fileName, $data, $packetName = NULL )
	{
		if( $packetName === NULL )
			$wddx	= wddx_serialize_value( $data );
		else
			$wddx	= wddx_serialize_value( $data, $packetName );
		return FS_File_Writer::save( $fileName, $wddx );
	}
69445
public function saveHTMLFile($filename)
    {
        if (!is_writable($filename)) {
            return false;
        }
        $result = $this->saveHTML();
        file_put_contents($filename, $result);
        $bytesWritten = filesize($filename);
        if ($bytesWritten === strlen($result)) {
            return $bytesWritten;
        }
        return false;
    }
623671
public function save($filename)
    {
        $type = pathinfo($filename, PATHINFO_EXTENSION);
        $type = ($type === 'jpg') ? 'jpeg' : $type;
        $type = (in_array($type, $this->imageTypes)) ? $type : 'png';

        header('Content-type: image/' . $type);

        $imageFunc = 'image' . $type;
        $imageFunc($this->image, $filename);

        $this->destroy($this->image);

        return $this;
    }
161342
private function updateFile($filename)
        {
                // fetch remote file:
                $file_contents = $this->fetchUrl(self::DOWNLOAD_BASE_URL.$filename);

        if ($file_contents === false) return false;

        if (sha1($file_contents) != $this->getCurrentFileHash($filename)) {
            try {
                throw new Exception("PHPIDS-Update: SHA1-hash of the downloaded file ($filename) is incorrect! (Download failed or Man-in-the-Middle). SHA1 of the file in the trunk: ".sha1($file_contents).", SHA1, provided by phpids.org: ".$this->getCurrentFileHash($filename));
            } catch (Exception $e) {
                return false;
            }
                }

                if (strlen($file_contents) <= 100) {
                        return false;
                }

                // overwrite file contents
                if (!file_put_contents($this->phpids_base.$filename, $file_contents)) {
                        return false;
                }

                return true;
        }