当前位置: 首页>>代码示例>>PHP>>正文


PHP ftp_fget函数代码示例

本文整理汇总了PHP中ftp_fget函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_fget函数的具体用法?PHP ftp_fget怎么用?PHP ftp_fget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ftp_fget函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 public function generate($log)
 {
     global $db;
     $host = "ftp.mozilla.org";
     $hostpos = strpos($this->logURL, $host);
     if ($hostpos === false) {
         throw new Exception("Log file {$this->logURL} not hosted on {$host}!");
     }
     $path = substr($this->logURL, $hostpos + strlen($host) + strlen("/"));
     $ftpstream = @ftp_connect($host);
     if (!@ftp_login($ftpstream, "anonymous", "")) {
         throw new Exception("Couldn't connect to Mozilla FTP server.");
     }
     $fp = tmpfile();
     if (!@ftp_fget($ftpstream, $fp, $path, FTP_BINARY)) {
         throw new Exception("Log not available at URL {$this->logURL}.");
     }
     ftp_close($ftpstream);
     rewind($fp);
     $db->beginTransaction();
     $stmt = $db->prepare("\n      UPDATE runs_logs\n      SET content = :content\n      WHERE buildbot_id = :id AND type = :type;");
     $stmt->bindParam(":content", $fp, PDO::PARAM_LOB);
     $stmt->bindParam(":id", $log['_id']);
     $stmt->bindParam(":type", $log['type']);
     $stmt->execute();
     $db->commit();
     fclose($fp);
 }
开发者ID:rhelmer,项目名称:tbpl,代码行数:28,代码来源:RawGzLogDownloader.php

示例2: fetchFile

 /**
  * Fetch data file from Itella FTP server
  * @param $type Data file type (PCF = localities, BAF = street addresses, POM = zip code changes)
  * @returns Temp file name
  */
 public function fetchFile($type)
 {
     //Connect to FTP server
     $ftp = ftp_connect($this->host);
     if ($ftp === false) {
         throw new Exception("Could not connect to '{$this->host}'");
     }
     if (!ftp_login($ftp, $this->user, $this->password)) {
         throw new Exception("Login to '{$this->host}' as '{$this->user}' failed");
     }
     //Find filename to download
     ftp_pasv($ftp, true);
     $list = ftp_nlist($ftp, '.');
     $file = null;
     foreach ($list as $item) {
         $parts = explode('_', $item);
         if (isset($parts[0]) && strtoupper($parts[0]) == strtoupper($type)) {
             $file = $item;
         }
     }
     if ($file == null) {
         throw new Exception("'{$type}' file not found");
     }
     //Download requested data file
     $tmpFile = tempnam(sys_get_temp_dir(), 'FinZip_' . $type . '_') . '.zip';
     $this->tmpFiles[] = $tmpFile;
     $tmp = fopen($tmpFile, 'w');
     ftp_pasv($ftp, true);
     ftp_fget($ftp, $tmp, $file, FTP_BINARY);
     ftp_close($ftp);
     fclose($tmp);
     //Return the filename of the temporary file
     return $tmpFile;
 }
开发者ID:tangervu,项目名称:finzip,代码行数:39,代码来源:FinZip.php

示例3: copyFileInStream

 public static function copyFileInStream($path, $stream)
 {
     $fake = new ftpAccessWrapper();
     $parts = $fake->parseUrl($path);
     $link = $fake->createFTPLink();
     $serverPath = AJXP_Utils::securePath($fake->path . "/" . $parts["path"]);
     ftp_fget($link, $stream, $serverPath, FTP_BINARY);
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:8,代码来源:class.ftpAccessWrapper.php

示例4: ftpGetContents

function ftpGetContents($ftpConn, $filepath, $ftpMode)
{
    // Create temp handler, this type needed for extended char set
    $tempHandle = fopen('php://temp', 'r+');
    // Get file from FTP assuming that it exists
    ftp_fget($ftpConn, $tempHandle, $filepath, $ftpMode, 0);
    // Return our content
    return stream_get_contents($tempHandle, -1, 0);
}
开发者ID:rasenderhase,项目名称:quocum,代码行数:9,代码来源:ftp-control.php

示例5: ftp_get_string

function ftp_get_string($ftp, $filename)
{
    $temp = fopen('php://temp', 'r+');
    if (@ftp_fget($ftp, $temp, $filename, FTP_BINARY, 0)) {
        rewind($temp);
        return stream_get_contents($temp);
    } else {
        return "Error reading data.";
    }
}
开发者ID:jtanx,项目名称:asweather,代码行数:10,代码来源:sydney.php

示例6: read

 /**
  * {@InheritDoc}
  */
 public function read($key)
 {
     $temp = fopen('php://temp', 'r+');
     if (!ftp_fget($this->getConnection(), $temp, $this->computePath($key), FTP_ASCII)) {
         throw new \RuntimeException(sprintf('Could not read the \'%s\' file.', $key));
     }
     rewind($temp);
     $contents = stream_get_contents($temp);
     fclose($temp);
     return $contents;
 }
开发者ID:ruudk,项目名称:Gaufrette,代码行数:14,代码来源:Ftp.php

示例7: read

 /**
  * {@inheritDoc}
  */
 public function read($key)
 {
     $temp = fopen('php://temp', 'r+');
     if (!ftp_fget($this->getConnection(), $temp, $this->computePath($key), $this->mode)) {
         return false;
     }
     rewind($temp);
     $contents = stream_get_contents($temp);
     fclose($temp);
     return $contents;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:14,代码来源:Ftp.php

示例8: executeGetFileAsBinary

 public function executeGetFileAsBinary($loginData, $file)
 {
     $conn = $this->_getConnexion($loginData);
     $tempHandle = fopen('php://temp', 'r+');
     $result = ftp_fget($conn, $tempHandle, $file, FTP_BINARY);
     if ($result !== false) {
         rewind($tempHandle);
         return array('contents' => base64_encode(stream_get_contents($tempHandle)));
     } else {
         throw new \RuntimeException('Cannot open file "' . $file . '"');
     }
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:12,代码来源:FTPController.class.php

示例9: getFileAsBinary

 protected function getFileAsBinary($loginData, $file)
 {
     $conn = $this->_getConnexion($loginData);
     $tempHandle = fopen('php://temp', 'r+');
     $result = @ftp_fget($conn, $tempHandle, $file, FTP_BINARY);
     if ($result !== false) {
         rewind($tempHandle);
         return array('contents' => base64_encode(stream_get_contents($tempHandle)));
     } else {
         throw new Exception('Impossible d\'accéder au fichier "' . $file . '"');
     }
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:12,代码来源:FTPController.class.php

示例10: _getFileContents

 public function _getFileContents($name)
 {
     $stream = fopen('php://temp', 'r+');
     if (@ftp_fget($this->getConnection(), $stream, $name, FTP_ASCII)) {
         rewind($stream);
         $contents = stream_get_contents($stream);
         fclose($stream);
         return $contents;
     } else {
         return false;
     }
 }
开发者ID:antimattr,项目名称:merchantry,代码行数:12,代码来源:FtpFileStore.php

示例11: _read

 function _read($path)
 {
     $this->_chdir(dirname($path));
     $tmpFile = tmpfile();
     ftp_fget($this->_link, $tmpFile, basename($path), FTP_BINARY);
     $content = "";
     fseek($tmpFile, 0);
     while (!feof($tmpFile)) {
         $content = $content . fread($tmpFile, 4096);
     }
     fclose($tmpFile);
     return $content;
 }
开发者ID:Rudi9719,项目名称:lucid,代码行数:13,代码来源:Ftp.php

示例12: testAppend

 public function testAppend()
 {
     $appendFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'append_source_file';
     $this->adapter->write($appendFilePath, 'foo', true);
     $temp = fopen('php://temp', 'r+');
     ftp_fget($this->connection, $temp, $appendFilePath, $this->mode);
     rewind($temp);
     $this->assertEquals('foo', stream_get_contents($temp));
     $this->adapter->write($appendFilePath, 'bar', true);
     rewind($temp);
     ftp_fget($this->connection, $temp, $appendFilePath, $this->mode);
     rewind($temp);
     $this->assertEquals('foobar', stream_get_contents($temp));
     fclose($temp);
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:15,代码来源:FtpAdapterTest.php

示例13: getfile

 public function getfile($filename)
 {
     if ($temp = $this->gettempfilehandle()) {
         fseek($temp, 0);
         ftruncate($temp, 0);
         if (@ftp_fget($this->handle, $temp, $filename, FTP_BINARY, $resumepos)) {
             fseek($temp, 0);
             $result = '';
             while (!feof($temp)) {
                 $result .= fread($temp, 8192);
             }
             return $result;
         }
     }
     return false;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:16,代码来源:remote.ftp.class.php

示例14: get

 public function get($fn, $target = null)
 {
     if (is_string($target)) {
         if (!ftp_get($this->_ftpStream, $target, $fn, FTP_ASCII)) {
             $target = false;
         }
     } else {
         if (is_null($target)) {
             $target = tmpfile();
         }
         if (!ftp_fget($this->_ftpStream, $target, $fn, FTP_ASCII)) {
             $target = false;
         }
     }
     return $target;
 }
开发者ID:OpenE2,项目名称:enigma2-php,代码行数:16,代码来源:enigma2.php

示例15: Download

 function Download($local_file, $remote_file)
 {
     //cria pasta temp caso não exista
     if (!file_exists(DOCUMENT_ROOT . NAME . '/ftp/temp')) {
         mkdir(DOCUMENT_ROOT . NAME . '/ftp/temp');
     }
     // open some file to write to
     $handle = fopen(DOCUMENT_ROOT . NAME . '/ftp' . $local_file, 'w');
     // try to download $remote_file and save it to $handle
     if (ftp_fget($this->Conn, $handle, $remote_file, FTP_ASCII, 0)) {
         echo "successfully written to {$local_file}\n";
         return true;
     } else {
         echo "There was a problem while downloading {$remote_file} to {$local_file}\n";
     }
 }
开发者ID:adrianosilvareis,项目名称:intranet,代码行数:16,代码来源:Ftp.class.php


注:本文中的ftp_fget函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。