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

PHP ftp_get函数代码示例

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

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



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

示例1: downloadFile

 public function downloadFile()
 {
     $requestURL = trim(Mage::getStoreConfig('pulliver/western_power/base_url'), ' /');
     $username = Mage::getStoreConfig('pulliver/western_power/username');
     $password = Mage::getStoreConfig('pulliver/western_power/password');
     $connection = ftp_connect($requestURL);
     if (!$connection) {
         Vikont_Pulliver_Helper_Data::inform(sprintf('Could not connect to %s', $requestURL));
     }
     if (!@ftp_login($connection, $username, $password)) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error logging to FTP %s as %s', $requestURL, $username));
     }
     $remoteFileName = Mage::getStoreConfig('pulliver/western_power/remote_filename');
     $localFileName = $this->getLocalFileName($remoteFileName, 'downloaded/');
     if (file_exists($localFileName)) {
         @unlink($localFileName);
     } else {
         if (!file_exists($dirName = dirname($localFileName))) {
             mkdir($dirName, 0777, true);
         }
     }
     Vikont_Pulliver_Helper_Data::type("Downloading {$requestURL}/{$remoteFileName}...");
     $startedAt = time();
     if (!ftp_get($connection, $localFileName, $remoteFileName, FTP_BINARY)) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error downloading from FTP %s/%s to %s', $requestURL, $remoteFileName, $localFileName));
     }
     ftp_close($connection);
     $timeTaken = time() - $startedAt;
     Vikont_Pulliver_Helper_Data::inform(sprintf('Inventory successfully downloaded from %s/%s to %s, size=%dbytes, time=%ds', $requestURL, $remoteFileName, $localFileName, filesize($localFileName), $timeTaken));
     return $localFileName;
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:31,代码来源:WesternPower.php


示例2: get_file

 /**
  * Function that retrieves a file from FTP library and compress it if necessary
  * 
  * @param string $file File name to be retrieved from FTP library
  * @return boolean
  */
 public function get_file($file, $dir = '')
 {
     if (!defined("LOCATION") || !defined("CODE") || !defined("LIBRARY") || !defined("CACHE_PATH")) {
         $this->container->__error("Imposible recuperar el archivo remoto: falta alguna constante por definir");
         return false;
     }
     $cnn = ftp_connect(LOCATION);
     $rs = ftp_login($cnn, LIBRARY, CODE);
     if ($rs === false) {
         $this->container->__error("Imposible conectar a la libreria de funciones!");
     }
     $dir = $dir == '' ? '' : $dir . DIRECTORY_SEPARATOR;
     ftp_chdir($cnn, LIBRARY . DIRECTORY_SEPARATOR . $dir);
     if (@ftp_chdir($cnn, $file) !== false) {
         if ($this->container->__debug()) {
             @mkdir(CACHE_PATH . $dir . $file);
             chmod(CACHE_PATH . $dir . $file, 0777);
             $dir = $dir == '' ? $file : $dir . $file;
         } else {
             @mkdir(CACHE_PATH . $dir . md5($file));
             chmod(CACHE_PATH . $dir . md5($file), 0777);
             $dir = $dir == '' ? $file : $dir . $file;
         }
         $files = ftp_nlist($cnn, ".");
         foreach ($files as $filea) {
             $this->get_file($filea, $dir);
         }
         return true;
     } else {
         if ($file == '.' || $file == '..') {
             return;
         }
         if ($this->container->__debug()) {
             $aux = ftp_get($cnn, CACHE_PATH . $dir . $file, $file, FTP_BINARY);
         } else {
             $temp = explode(DIRECTORY_SEPARATOR, $dir);
             array_walk($temp, function (&$element, $index) {
                 $element = md5($element);
             });
             array_pop($temp);
             $temp = implode(DIRECTORY_SEPARATOR, $temp) . DIRECTORY_SEPARATOR;
             $aux = ftp_get($cnn, CACHE_PATH . $temp . md5($file), $file, FTP_BINARY);
         }
         if (!$aux) {
             ftp_close($cnn);
             $this->container->__error("Imposible obtener el archivo para cache: " . $file);
             return false;
         } else {
             ftp_close($cnn);
             if ($this->container->__debug()) {
                 chmod(CACHE_PATH . $dir . $file, 0777);
                 $this->compress_cache_file($dir . $file);
             } else {
                 chmod(CACHE_PATH . $temp . md5($file), 0777);
                 $this->compress_cache_file($temp . md5($file));
             }
             return true;
         }
     }
 }
开发者ID:fran-diaz,项目名称:ite,代码行数:66,代码来源:cache.php


示例3: GetMD5

function GetMD5()
{
    global $ftp;
    global $dir;
    global $remote_file;
    $md5 = null;
    $checksum_file = str_replace('.installer.exe', '.checksums', $remote_file);
    $local_checksums = 'nightly-checksums.dat';
    if (is_file($local_checksums)) {
        unlink($local_checksums);
    }
    if (ftp_get($ftp, $local_checksums, "{$dir}{$checksum_file}", FTP_ASCII)) {
        $checksums = file($local_checksums);
        if ($checksums && is_array($checksums)) {
            foreach ($checksums as $line) {
                if (strstr($line, $remote_file) !== FALSE) {
                    list($hash, $type, $size, $file) = explode(' ', trim($line));
                    if ($type == 'md5') {
                        $md5 = $hash;
                        break;
                    }
                }
            }
        }
    }
    if (is_file($local_checksums)) {
        unlink($local_checksums);
    }
    return $md5;
}
开发者ID:nowol79,项目名称:webpagetest-1,代码行数:30,代码来源:updateFirefoxNightly.php


示例4: actionSynchronization

 public function actionSynchronization()
 {
     if (date('w', time()) == 0 || date('w', time()) == 6) {
         return;
     }
     $transfer_src = ftp_connect('91.197.79.112');
     $login_result = ftp_login($transfer_src, 'transfer', 'dnUtd74n');
     if (!$login_result) {
         return false;
     }
     ftp_pasv($transfer_src, TRUE);
     $files = ftp_nlist($transfer_src, ".");
     foreach ($files as $file) {
         if (!is_file(Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file)) {
             $transfer_dst = ftp_connect('37.46.85.148');
             $login_result = ftp_login($transfer_dst, 'carakas', 'hokwEw21');
             if (!$login_result) {
                 return false;
             }
             ftp_pasv($transfer_dst, TRUE);
             ftp_get($transfer_src, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, $file, FTP_ASCII);
             ftp_put($transfer_dst, $file, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, FTP_BINARY);
             ftp_close($transfer_dst);
         }
     }
     ftp_close($transfer_src);
 }
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:27,代码来源:DefaultController.php


示例5: lista_detallada

 private function lista_detallada($resource, $directorio = '.')
 {
     if (is_array($children = @ftp_rawlist($resource, $directorio))) {
         $items = array();
         foreach ($children as $child) {
             $chunks = preg_split("/\\s+/", $child);
             list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
             $item['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
             array_splice($chunks, 0, 8);
             $items[implode(" ", $chunks)] = $item;
             //$chunks contiene el nombre del archivo
             //echo "\n chunks---------------------------------\n";
             //print_r($chunks);
             //echo "\n";
             // descargo archivo si tiene extension txt
             if (substr($chunks[0], -4) == ".txt") {
                 $local_file = "temp/" . $chunks[0];
                 $server_file = $chunks[0];
                 if (!file_exists($local_file)) {
                     //si el archivo no existe lo descargo
                     if (ftp_get($resource, $local_file, $server_file, FTP_ASCII)) {
                         echo "Se descargo archivo\n";
                     } else {
                         echo "ERROR! No se pudo descargar archivo\n";
                     }
                 }
             }
         }
         return $items;
     }
     return false;
 }
开发者ID:pjg711,项目名称:alerta-sondas-detenidas,代码行数:32,代码来源:class_ftp.php


示例6: get

 /**
  * @inheritdoc
  */
 public function get($localFile, $remoteFile, $mode = FTP_ASCII)
 {
     if (false === ftp_get($this->getFtp(), $localFile, $remoteFile, $mode)) {
         throw new \Exception("Unable to get file:" . $remoteFile);
     }
     return true;
 }
开发者ID:acassan,项目名称:remoteserver,代码行数:10,代码来源:Ftp.php


示例7: get

 function get($local, $remote, $mode = null)
 {
     if ($mode === null) {
         $mode = FTP_BINARY;
     }
     return ftp_get($this->res, $local, $remote, $mode);
 }
开发者ID:nuxodin,项目名称:shwups-cms-v4,代码行数:7,代码来源:Ftp.class.php


示例8: ftp_sync

function ftp_sync($dir)
{
    global $conn_id;
    if ($dir != ".") {
        if (ftp_chdir($conn_id, $dir) == false) {
            echo "Change Dir Failed: {$dir}<BR>\r\n";
            return;
        }
        if (!is_dir($dir)) {
            mkdir($dir);
        }
        chdir($dir);
    }
    $contents = ftp_nlist($conn_id, ".");
    foreach ($contents as $file) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (@ftp_chdir($conn_id, $file)) {
            ftp_chdir($conn_id, "..");
            ftp_sync($file);
        } else {
            ftp_get($conn_id, $file, $file, FTP_BINARY);
        }
    }
    ftp_chdir($conn_id, "..");
    chdir("..");
}
开发者ID:mrj0909,项目名称:sf,代码行数:28,代码来源:ftp_transfer.php


示例9: download

 public function download(string $remotePath, string $localPath, string $type = 'ascii') : bool
 {
     if (ftp_get($this->connect, $localPath, $remotePath, Converter::toConstant($type, 'FTP_'))) {
         return true;
     } else {
         throw new FileRemoteDownloadException($localPath);
     }
 }
开发者ID:znframework,项目名称:znframework,代码行数:8,代码来源:Transfer.php


示例10: get

 /**
  * Downloads a remote file
  * @link http://php.net/ftp_get
  *
  * @param  string  $localFile  The local file path
  * @param  string  $remoteFile The remote file path
  * @param  integer $mode       The transfer mode (FTPWrapper::ASCII, FTPWrapper::BINARY)
  * @param  integer $resumepos  The position in the remote file to start downloading from
  * @return boolean TRUE on success, FALSE on failure
  */
 public function get($localFile, $remoteFile, $mode = self::BINARY, $resumepos = 0)
 {
     try {
         return ftp_get($this->connection->getStream(), $localFile, $remoteFile, $mode, $resumepos);
     } catch (\Exception $e) {
         return ftp_get($this->connection->getStream(), $localFile, str_replace(' ', '\\ ', $remoteFile), $mode, $resumepos);
     }
 }
开发者ID:portey,项目名称:php-ftp-wrapper,代码行数:18,代码来源:FTPWrapper.php


示例11: download

 /**
  * Downloads file
  *
  * @param string $localName Path to save the file
  * @param int $mode The transfer mode, <code>FTP_ASCII</code> or <code>FTP_BINARY</code>
  * @param int $startPos The position in the remote file to start downloading from
  * @throws cFTP_Exception
  * 
  * @return cFTP_File This
  */
 public function download($localName, $mode = FTP_BINARY, $startPos = 0)
 {         
     $success = @ftp_get( $this->handle, $localName, $this->name, $mode, $startPos );
  
     if( !$success )
         throw new cFTP_Exception( "Could not download file", 30 );
     
     return $this;
 }
开发者ID:robik,项目名称:cFTP,代码行数:19,代码来源:File.php


示例12: download

 public function download($file, $path, $mode = FTP_BINARY)
 {
     if (isset($file)) {
         if (ftp_get($this->ftpcon, $path, $file, FTP_BINARY)) {
             return true;
         }
     }
     return false;
 }
开发者ID:supertorti,项目名称:FRAMEWORK,代码行数:9,代码来源:ftp_connect_class.php


示例13: bajar_r

 function bajar_r($from, $to, $retries = 1)
 {
     $tries = 0;
     $bajado = false;
     while (!$bajado && $tries < $retries) {
         $bajado = ftp_get($this->id_conn, $to, $from, FTP_BINARY);
         $tries++;
     }
     return $bajado;
 }
开发者ID:vallejos,项目名称:samples,代码行数:10,代码来源:ftp.class.php


示例14: copy_file

 /**
  * 方法:复制文件 
  * 说明:由于FTP无复制命令,本方法变通操作为:下载后再上传到新的路径 
  * @path    -- 原路径 
  * @newpath -- 新路径 
  * @type    -- 若目标目录不存在则新建 
  */
 function copy_file($path, $newpath, $type = true)
 {
     $downpath = "c:/tmp.dat";
     $this->off = @ftp_get($this->conn_id, $downpath, $path, FTP_BINARY);
     // 下载
     if (!$this->off) {
         echo "文件复制失败,请检查权限及原路径是否正确!";
     }
     $this->up_file($downpath, $newpath, $type);
 }
开发者ID:8yong8,项目名称:vshop,代码行数:17,代码来源:Ftp.class.php


示例15: copy_file

 /** 
  * 方法:复制文件 
  * 说明:由于FTP无复制命令,本方法变通操作为:下载后再上传到新的路径 
  * @path    -- 原路径 
  * @newpath -- 新路径 
  * @type    -- 若目标目录不存在则新建 
  */
 function copy_file($path, $newpath, $type = true)
 {
     $downpath = "c:/tmp.dat";
     $this->off = @ftp_get($this->conn_id, $downpath, $path, FTP_BINARY);
     // 下载
     if (!$this->off) {
         return false;
     } else {
         return $this->up_file($downpath, $newpath, $type);
     }
 }
开发者ID:codingoneapp,项目名称:codingone,代码行数:18,代码来源:ftp.php


示例16: getBouquets

 public function getBouquets($folderName)
 {
     // TODO delete old files
     $files = ftp_nlist($this->_ftpStream, '/etc/enigma2/');
     foreach ($files as $fn) {
         if (pathinfo($fn, PATHINFO_EXTENSION) == 'tv') {
             $target = $folderName . DIRECTORY_SEPARATOR . pathinfo($fn, PATHINFO_BASENAME);
             ftp_get($this->_ftpStream, $target, $fn, FTP_ASCII);
         }
     }
 }
开发者ID:OpenE2,项目名称:enigma2-php,代码行数:11,代码来源:enigma2.php


示例17: read

 public function read($dest)
 {
     $tempFile = tempnam(sys_get_temp_dir(), '');
     $destFullPath = $this->getOption('path') . $dest;
     if (false === ftp_get($this->_getConnection(), $tempFile, $destFullPath, FTP_BINARY)) {
         return false;
     }
     $str = file_get_contents($tempFile);
     unlink($tempFile);
     return $str;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:11,代码来源:Ftp.php


示例18: get_contents

 function get_contents($file)
 {
     if ($ftp = AkFtpClient::connect()) {
         $file = str_replace('\\', '/', $file);
         $tmpfname = tempnam('/tmp', 'tmp');
         ftp_get($ftp, $tmpfname, $file, FTP_BINARY);
         $file_contents = @file_get_contents($tmpfname);
         unlink($tmpfname);
         return $file_contents;
     }
 }
开发者ID:BackupTheBerlios,项目名称:phpbase-svn,代码行数:11,代码来源:AkFtpClient.php


示例19: get_file

 function get_file($local, $remote)
 {
     global $strErrFtpNoGet;
     @ftp_pasv($this->ftpc, true);
     $download = @ftp_get($this->ftpc, $local, $remote, FTP_BINARY);
     if (!$download) {
         AA_printErrorMsg($strErrFtpNoGet);
         return false;
     } else {
         return true;
     }
 }
开发者ID:laiello,项目名称:athletica,代码行数:12,代码来源:cl_ftp_data.lib.php


示例20: nobget

 public function nobget($local,$remote) {
     if(!$this->connid) {
         $this->errorid = 2;
         return false;
     }
     if(@ftp_get($this->connid,$local,$remote,$this->connmode)) {
         return true;
     }else {
         $this->errorid = 8;
         return false;
     }
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:12,代码来源:nobftp.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ftp_get_option函数代码示例发布时间:2022-05-15
下一篇:
PHP ftp_fput函数代码示例发布时间: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