本文整理匯總了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();
}