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


PHP ftp_chdir函数代码示例

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


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

示例1: mchdir

 function mchdir($directory)
 {
     if (!$this->conn_id) {
         return false;
     }
     return @ftp_chdir($this->conn_id, $directory);
 }
开发者ID:polarlight1989,项目名称:08cms,代码行数:7,代码来源:ftp.fun.php

示例2: getConnection

 protected function getConnection()
 {
     if ($this->connection === null) {
         // Connect using FTP
         if ($this->getConnectType() === self::CONNECT_TYPE_FTP) {
             $port = empty($this->getPort()) ? 21 : $this->getPort();
             $this->connection = ftp_connect($this->getHost(), $port);
             if (!$this->connection) {
                 throw new \ErrorException('Failed to connect to FTP');
             }
             if (!ftp_login($this->connection, $this->getUsername(), $this->getPassword())) {
                 throw new \ErrorException('Wrong username/password provided to FTP.');
             }
             if ($this->getStartDirectory()) {
                 if (!ftp_chdir($this->connection, $this->getStartDirectory())) {
                     throw new \ErrorException('Failed to set start directory');
                 }
             }
         } elseif ($this->getConnectType() === self::CONNECT_TYPE_SFTP) {
             $port = empty($this->getPort()) ? 22 : $this->getPort();
             $this->settings = ['host' => $this->getHost(), 'port' => $port, 'username' => $this->getUsername(), 'password' => $this->getPassword(), 'timeout' => 10, 'directoryPerm' => 0755];
             if (!empty($this->getStartDirectory())) {
                 $settings['root'] = $this->getStartDirectory();
             }
             $this->connection = new SftpAdapter($settings);
         } else {
             throw new \ErrorException('Invalid connection-type');
         }
     }
     return $this->connection;
 }
开发者ID:Monori,项目名称:imgservice,代码行数:31,代码来源:SourceFtp.php

示例3: envia_archivo_via_ftp

function envia_archivo_via_ftp($cadena, $nombre_archivo_remoto = "", $mensajes = 0)
{
    $fp = fopen("temp.txt", "w");
    if (fwrite($fp, utf8_encode($cadena))) {
        $ftp_sitio = CONFIG("FE_RESPALDO_SITIO");
        $ftp_usuario = CONFIG("FE_RESPALDO_SITIO_USUARIO");
        $ftp_pass = CONFIG("FE_RESPALDO_SITIO_CLAVE");
        $conn = ftp_connect($ftp_sitio) or die("Acceso incorrecto.. " . $ftp_sitio);
        ftp_login($conn, $ftp_usuario, $ftp_pass);
        ftp_chdir($conn, CONFIG("FE_RESPALDO_SITIO_DIR"));
        //echo $ftp_sitio."--".$ftp_usuario."--".$ftp_pass."--".CONFIG("FE_RESPALDO_SITIO_DIR");
        if (ftp_size($conn, $nombre_archivo_remoto) != -1) {
            if ($mensajes) {
                echo "Ya existe este envio, no se realizo nuevamente..";
            }
        } else {
            if (ftp_put($conn, $nombre_archivo_remoto, "temp.txt", FTP_ASCII)) {
                if ($mensajes) {
                    echo "Envio exitoso.... ok";
                } else {
                    if ($mensajes) {
                        echo "Hubo un problema durante la transferencia ...";
                    }
                }
            }
        }
        ftp_close($conn);
    }
    fclose($fp);
}
开发者ID:alexlqi,项目名称:adminteprod,代码行数:30,代码来源:funciones_generales.php

示例4: exists

 public function exists($path)
 {
     if (!$this->stream) {
         $this->connectAndLogin();
     }
     $pwd = ftp_pwd($this->stream);
     // try to change directory to see if it is an existing directory
     $result = @ftp_chdir($this->stream, $path);
     if (true === $result) {
         ftp_chdir($this->stream, $pwd);
         // change back to the original directory
         return true;
     } else {
         // list the parent directory and check if the file exists
         $parent = dirname($path);
         $options = '-a';
         // list hidden
         $result = ftp_rawlist($this->stream, $options . ' ' . $parent);
         if (false !== $result) {
             foreach ($result as $line) {
                 if (false !== ($pos = strrpos($line, basename($path)))) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:28,代码来源:FtpTransporter.php

示例5: make_collection

 public function make_collection($path)
 {
     $path = $this->get_encoded_path($path);
     if (false === ($conn = $this->get_connection_handle())) {
         throw new Exception("Could not connect to FTP server.");
     }
     if ('/' == $path[0]) {
         $path = substr($path, 1);
     }
     if ('/' == substr($path, -1)) {
         $path = substr($path, 0, -1);
     }
     $path_parts = explode('/', $path);
     for ($i = 0; $i < sizeof($path_parts) - 1; $i++) {
         if (false === @ftp_chdir($conn, $path_parts[$i])) {
             $this->throw_exception("Could not change to directory `{$path_parts[$i]}'.");
         }
     }
     $label = $path_parts[sizeof($path_parts) - 1];
     if (false === @ftp_mkdir($conn, $label)) {
         $this->throw_exception("Could not make directory `{$label}'.");
     }
     @ftp_close($conn);
     return true;
 }
开发者ID:aprilchild,项目名称:aprilchild,代码行数:25,代码来源:ftp_client.php

示例6: ftpMkDir

function ftpMkDir($path, $newDir, $ftpServer, $ftpUser, $ftpPass)
{
    $server = $ftpServer;
    // ftp server
    $connection = ftp_connect($server);
    // connection
    // login to ftp server
    $user = $ftpUser;
    $pass = $ftpPass;
    $result = ftp_login($connection, $user, $pass);
    // check if connection was made
    if (!$connection || !$result) {
        return false;
        exit;
    } else {
        ftp_chdir($connection, $path);
        // go to destination dir
        if (ftp_mkdir($connection, $newDir)) {
            // create directory
            return $newDir;
        } else {
            return false;
        }
        ftp_close($connection);
        // close connection
    }
}
开发者ID:utilo-web-app-development,项目名称:REZERVI,代码行数:27,代码来源:filesAndFolders.inc.php

示例7: enviaImagen

function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen)
{
    $host = 'ftp.laraandalucia.com';
    $usuario = 'laraandalucia.com';
    $pass = '2525232';
    $errorFtp = 'no';
    $dirServ = 'html/images/Lara/' . $fDirServ;
    $conexion = @ftp_connect($host);
    if ($conexion) {
        if (@ftp_login($conexion, $usuario, $pass)) {
            if (!@ftp_chdir($conexion, $dirServ)) {
                if (!@ftp_mkdir($conexion, $dirServ)) {
                    $errorFtp = 'si';
                }
            }
        } else {
            $errorFtp = 'si';
        }
    } else {
        $errorFtp = 'si';
    }
    if ($errorFtp = 'no') {
        @ftp_chdir($conexion, $dirServ);
        if (@(!ftp_put($conexion, $fNombreImagen, $fRutaImagen, FTP_BINARY))) {
            $errorFtp = 'si';
        }
    }
    @ftp_quit($conexion);
    return $errorFtp == 'no';
}
开发者ID:amarser,项目名称:cmi,代码行数:30,代码来源:ManchaLlana.php

示例8: store

 /**
  * Store it locally
  * @param  string $fullPath    Full path from local system being saved
  * @param  string $filename Filename to use on saving
  */
 public function store($fullPath, $filename)
 {
     if ($this->connection == false) {
         $result = array('error' => 1, 'message' => "Unable to connect to ftp server!");
         return $result;
     }
     //prepare dir path to be valid :)
     $this->remoteDir = rtrim($this->remoteDir, "/") . "/";
     try {
         $originalDirectory = ftp_pwd($this->connection);
         // test if you can change directory to remote dir
         // suppress errors in case $dir is not a file or not a directory
         if (@ftp_chdir($this->connection, $this->remoteDir)) {
             // If it is a directory, then change the directory back to the original directory
             ftp_chdir($this->connection, $originalDirectory);
         } else {
             if (!ftp_mkdir($this->connection, $this->remoteDir)) {
                 $result = array('error' => 1, 'message' => "Remote dir does not exist and unable to create it!");
             }
         }
         //save file to local dir
         if (!ftp_put($this->connection, $this->remoteDir . $filename, $fullPath, FTP_BINARY)) {
             $result = array('error' => 1, 'message' => "Unable to send file to ftp server");
             return $result;
         }
         //prepare and return result
         $result = array('storage_path' => $this->remoteDir . $filename);
         return $result;
     } catch (Exception $e) {
         //unable to copy file, return error
         $result = array('error' => 1, 'message' => $e->getMessage());
         return $result;
     }
 }
开发者ID:mukulmantosh,项目名称:maratus-php-backup,代码行数:39,代码来源:Ftp.php

示例9: cd

 /**
  * Change Directory
  * @param string $dir
  * @return ftp
  *
  */
 public function cd($dir)
 {
     $dir = (string) $dir;
     $dir === '..' ? ftp_cdup($this->ftp) : ftp_chdir($this->ftp, $dir);
     $this->path = $this->pwd();
     return $this;
 }
开发者ID:shgysk8zer0,项目名称:core,代码行数:13,代码来源:ftp.php

示例10: isDir

	/**
	 * Check if the URL is a folder or not
	 * @param $path The file path
	 * @return Boolean
	 */
	public static function isDir($path){
		$chDir = @ftp_chdir(self::$conn, $path);
		if($chDir){
			return TRUE;
		}
		return FALSE;
	}
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:12,代码来源:ocDownloaderFTP.class.php

示例11: chdir

 /**
  * Change directories
  *
  * @param  string $dir
  * @throws Exception
  * @return Ftp
  */
 public function chdir($dir)
 {
     if (!ftp_chdir($this->connection, $dir)) {
         throw new Exception('Error: There was an error changing to the directory ' . $dir);
     }
     return $this;
 }
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:14,代码来源:Ftp.php

示例12: addDir

 private function addDir($dir, $display)
 {
     $chDir = $this->targetDirectory . dirname($dir);
     $mkDir = basename($dir);
     if ($this->testMode) {
         $this->messages[] = "Test mode, Add directory, {$mkDir} to {$chDir}";
         if ($display) {
             echo end($this->messages), "\n";
         }
     } else {
         if (@ftp_chdir($this->conn_id, $chDir) === false) {
             $this->messages[] = "Could not change directory to {$chDir}";
             if ($display) {
                 echo end($this->messages), "\n";
             }
         } else {
             if (($newDir = @ftp_mkdir($this->conn_id, $mkDir)) === false) {
                 $this->messages[] = "Could not Add directory, {$mkDir} to {$chDir}";
                 if ($display) {
                     echo end($this->messages), "\n";
                 }
             } else {
                 $this->messages[] = "Add directory, {$mkDir} to {$chDir}";
                 if ($display) {
                     echo end($this->messages), "\n";
                 }
             }
         }
     }
 }
开发者ID:raxisau,项目名称:JackBooted,代码行数:30,代码来源:DeployChangeset.php

示例13: getListing

 public function getListing()
 {
     $dir = $this->directory;
     // Parse directory to parts
     $parsed_dir = trim($dir, '/');
     $this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
     // Find the path to the parent directory
     if (!empty($parts)) {
         $copy_of_parts = $parts;
         array_pop($copy_of_parts);
         if (!empty($copy_of_parts)) {
             $this->parent_directory = '/' . implode('/', $copy_of_parts);
         } else {
             $this->parent_directory = '/';
         }
     } else {
         $this->parent_directory = '';
     }
     // Connect to the server
     if ($this->ssl) {
         $con = @ftp_ssl_connect($this->host, $this->port);
     } else {
         $con = @ftp_connect($this->host, $this->port);
     }
     if ($con === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_HOSTNAME'));
         return false;
     }
     // Login
     $result = @ftp_login($con, $this->username, $this->password);
     if ($result === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_USERPASS'));
         return false;
     }
     // Set the passive mode -- don't care if it fails, though!
     @ftp_pasv($con, $this->passive);
     // Try to chdir to the specified directory
     if (!empty($dir)) {
         $result = @ftp_chdir($con, $dir);
         if ($result === false) {
             $this->setError(JText::_('FTPBROWSER_ERROR_NOACCESS'));
             return false;
         }
     } else {
         $this->directory = @ftp_pwd($con);
         $parsed_dir = trim($this->directory, '/');
         $this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
         $this->parent_directory = $this->directory;
     }
     // Get a raw directory listing (hoping it's a UNIX server!)
     $list = @ftp_rawlist($con, '.');
     ftp_close($con);
     if ($list === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_UNSUPPORTED'));
         return false;
     }
     // Parse the raw listing into an array
     $folders = $this->parse_rawlist($list);
     return $folders;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:60,代码来源:ftpbrowsers.php

示例14: connect

 /**
  * Connect to ftp server
  *
  * @return bool
  **/
 protected function connect()
 {
     if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
         return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
     }
     if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
         $this->umount();
         return $this->setError('Unable to login into ' . $this->options['host']);
     }
     // switch off extended passive mode - may be usefull for some servers
     //@ftp_exec($this->connect, 'epsv4 off' );
     // enter passive mode if required
     $this->options['mode'] = 'active';
     ftp_pasv($this->connect, $this->options['mode'] == 'passive');
     // enter root folder
     if (!ftp_chdir($this->connect, $this->root)) {
         $this->umount();
         return $this->setError('Unable to open root folder.');
     }
     $stat = array();
     $stat['name'] = $this->root;
     $stat['mime'] = 'directory';
     $this->filesCache[$this->root] = $stat;
     $this->cacheDir($this->root);
     return true;
 }
开发者ID:scorpionx,项目名称:vtt-bundle,代码行数:31,代码来源:elFinderVolumeFTPIIS.php

示例15: ftp

 public function ftp($host = '', $user = '', $password = '', $rootdir = './', $port = 21)
 {
     if (defined('C_FTP_METHOD')) {
         $this->_method = C_FTP_METHOD;
     }
     if ($this->_method == 'PHP') {
         //echo 'PHPMODE: ';
         $rootdir = LITO_ROOT_PATH;
         if (!is_dir($rootdir)) {
             return false;
         }
         $this->rootdir = preg_replace('!\\/$!', '', $rootdir);
         $this->connected = true;
         $this->lito_root = true;
         //echo 'Useing PHP as a workaround!';
     } else {
         $this->_host = $host;
         $this->_port = $port;
         $this->_user = $user;
         $this->_password = $password;
         if (!@($this->_connection = ftp_connect($this->_host, $this->_port))) {
             return false;
         }
         if (!@ftp_login($this->_connection, $this->_user, $this->_password)) {
             return false;
         }
         $this->connected = true;
         ftp_chdir($this->_connection, $rootdir);
         //if ($this->exists('litotex.php'))
         $this->lito_root = true;
     }
 }
开发者ID:Wehmeyer,项目名称:Litotex-0.7,代码行数:32,代码来源:ftp_class.php


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