• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ftp_fget函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SaveComment

function SaveComment($id, $comment)
{
    $temp = fopen('php://temp', 'r+');
    $ftp = GetFtpHandle();
    if ($ftp !== false) {
        ftp_fget($ftp, $temp, $id . ".comment", FTP_BINARY, 0);
        fwrite($temp, $comment . "\r\n");
        rewind($temp);
        if (ftp_fput($ftp, $id . ".comment", $temp, FTP_BINARY)) {
            fclose($temp);
            ftp_close($ftp);
            return true;
        }
        ftp_close($ftp);
    }
    fclose($temp);
    return false;
}
开发者ID:0140454,项目名称:WebCourse,代码行数:18,代码来源:comment.php


示例17: get

 /**
  * public function get
  *
  *
  * @param    string $file
  * @return   string
  */
 public function get($file = '')
 {
     $tempHandle = fopen('php://temp', 'r+');
     $sizeFile = $this->size($file);
     if ($sizeFile > 512000) {
         // 512 000 KB
         return 'This file is too big to read, maximum filesize allowed to the browser: 512KB';
     } else {
         if (@ftp_fget($this->connection, $tempHandle, $file, FTP_ASCII, 0)) {
             rewind($tempHandle);
             $total = stream_get_contents($tempHandle);
             return $total;
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:NathanGeerinck,项目名称:LaravelFtp,代码行数:25,代码来源:Ftp.php


示例18: open_from_ftp

/**
 * @return String/FALSE on error
 * @param String $server
 * @param String $port
 * @param String $pasv
 * @param String $username
 * @param String $password
 * @param String $file
 * @desc Connects to an FTP server, requests the specified file, writes it to
 *       a temporary location and then loads it into a string.
 */
function open_from_ftp($server, $port = '', $pasv, $username, $password, $file)
{
    global $javascript_msg;
    // Set the port we're using
    $port = isset($port) && $port != '' ? $port : 0;
    // Connect to FTP Server
    if ($ftp = @ftp_connect($server, $port)) {
        // Log in using details provided
        if ($logged_in = @ftp_login($ftp, $username, $password)) {
            // Set PASV mode
            ftp_pasv($ftp, $pasv);
            // Create a temporary file, and get the remote file contents into it.
            $temp_file = 'temp/' . date('YmdHis') . '.wp';
            if ($local_file = @fopen($temp_file, 'wt')) {
                if (@ftp_fget($ftp, $local_file, $file, FTP_ASCII)) {
                    @ftp_quit($ftp);
                    fclose($local_file);
                    // Make sure that the file parsing function exists, or grab code for it
                    if (!function_exists('parse_file')) {
                        require_once 'common.php';
                    }
                    $string = parse_file($temp_file);
                    return $string;
                } else {
                    $javascript_msg = '@Could not get the file from the FTP Server.';
                    return false;
                }
            } else {
                $javascript_msg = '@Could not create temporary file. Check the permissions on webpad\'s temporary folder.';
                return false;
            }
        } else {
            $javascript_msg = '@Authentication failed on FTP Server \'' . $server . '\'.';
            return false;
        }
    } else {
        $javascript_msg = '@Could not connect to FTP Server \'' . $server . '\'.';
        return false;
    }
}
开发者ID:anboto,项目名称:xtreamer-web-sdk,代码行数:51,代码来源:ftp.php


示例19: stream_open

 /**
  * Opens the strem
  *
  * @param String $path Maybe in the form "ajxp.ftp://repositoryId/pathToFile" 
  * @param String $mode
  * @param unknown_type $options
  * @param unknown_type $opened_path
  * @return unknown
  */
 function stream_open($path, $mode, $options, &$opened_path)
 {
     $url = parse_url($path);
     $repoId = $url["host"];
     $repoObject = ConfService::getRepositoryById($repoId);
     if (!isset($repoObject)) {
         return false;
     }
     $this->repository = $repoObject;
     $this->user = $this->getUserName($repoObject);
     $this->password = $this->getPassword($repoObject);
     $res = $this->initRepository();
     $this->path = $this->secureFtpPath($this->path . "/" . $url["path"]);
     if ($mode == "r") {
         if ($contents = @ftp_rawlist($this->connect, $this->path) !== FALSE) {
             $this->cacheRHandler = tmpfile();
             @ftp_fget($this->connect, $this->cacheRHandler, $this->path, FTP_BINARY, 0);
             rewind($this->cacheRHandler);
         }
     }
     return true;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:31,代码来源:class.ftpAccessWrapper.php


示例20: get_contents

 function get_contents($file, $type = '', $resumepos = 0)
 {
     if (empty($type)) {
         $extension = substr(strrchr($file, "."), 1);
         $type = isset($this->filetypes[$extension]) ? $this->filetypes[$extension] : FTP_ASCII;
     }
     $temp = tmpfile();
     if (!$temp) {
         return false;
     }
     if (!@ftp_fget($this->link, $temp, $file, $type, $resumepos)) {
         return false;
     }
     fseek($temp, 0);
     //Skip back to the start of the file being written to
     $contents = '';
     while (!feof($temp)) {
         $contents .= fread($temp, 8192);
     }
     fclose($temp);
     return $contents;
 }
开发者ID:nurpax,项目名称:saastafi,代码行数:22,代码来源:class-wp-filesystem-ftpext.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ftp_fput函数代码示例发布时间:2022-05-15
下一篇:
PHP ftp_exec函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap