当前位置: 首页>>代码示例>>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;未经允许,请勿转载。