本文整理汇总了PHP中Ftp::fget方法的典型用法代码示例。如果您正苦于以下问题:PHP Ftp::fget方法的具体用法?PHP Ftp::fget怎么用?PHP Ftp::fget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ftp
的用法示例。
在下文中一共展示了Ftp::fget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDownload
/**
* Download test.
* @return void
*/
public function testDownload()
{
$ftp = new Ftp();
// Opens an FTP connection to the specified host
$ftp->connect('ftp.nettephp.com');
$ftp->pasv(TRUE);
// Login with username and password
$ftp->login('nette@php7.org', 'anonymous');
// Download file 'README' to local temporary file
$temp = tmpfile();
$ftp->fget($temp, 'README', Ftp::ASCII);
// echo file
fseek($temp, 0);
$this->assertEquals("Nette Framework rocks!", stream_get_contents($temp));
}
示例2: getGitDiff
/**
* Gets a list of files to be uploaded based on the difference between HEAD
* and the commit last deployed.
*
* @param \Ftp $ftp An active FTP connection.
*
* @return string[] An array of file names to upload.
*/
protected function getGitDiff(\Ftp $ftp)
{
$this->printTaskInfo('Checking remote site for Git info...');
$ftp->chdir($this->targetDirectory);
if (in_array('.git-commit', $ftp->nlist('.'))) {
$tempHandle = fopen('php://temp', 'r+');
if ($ftp->fget($tempHandle, '.git-commit', FTP_ASCII, 0)) {
rewind($tempHandle);
$commitId = stream_get_contents($tempHandle);
$this->printTaskInfo('Remote site has version ' . $commitId . '.');
$this->printTaskInfo(' Scanning for changes...');
$result = $this->taskExec('git')->arg('diff')->arg('--name-only')->arg('--diff-filter=ACMRT')->arg($commitId)->arg('HEAD')->run();
return preg_split('/[\\r\\n]+/', trim($result->getMessage()));
}
}
$this->printTaskInfo('No Git info found on remote site.');
$this->printTaskInfo('Adding all files in repo...');
// No commit saved on remote site; deploy everything in repo
$result = $this->taskExec('git')->arg('ls-files')->run();
return preg_split('/[\\r\\n]+/', trim($result->getMessage()));
}
示例3: Ftp
<?php
require_once 'ftp.class.php';
try {
$ftp = new Ftp();
// Opens an FTP connection to the specified host
$ftp->connect('ftp.ed.ac.uk');
// Login with username and password
$ftp->login('anonymous', 'example@example.com');
// Download file 'README' to local temporary file
$temp = tmpfile();
$ftp->fget($temp, 'README', Ftp::ASCII);
// echo file
echo '<pre>';
fseek($temp, 0);
fpassthru($temp);
} catch (FtpException $e) {
echo 'Error: ', $e->getMessage();
}