當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ftp::fget方法代碼示例

本文整理匯總了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));
 }
開發者ID:vrana,項目名稱:nette,代碼行數:19,代碼來源:NetteWebFtpTest.php

示例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()));
 }
開發者ID:coderstephen,項目名稱:robo-ftp,代碼行數:29,代碼來源:FtpDeployTask.php

示例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();
}
開發者ID:liulingfu,項目名稱:madserve,代碼行數:19,代碼來源:example.php


注:本文中的Ftp::fget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。