php中ftp_chdir与ftp_cdup函数用法_PHP

WBOY
Release: 2016-05-31 19:27:46
Original
1260 people have browsed it

本文实例讲述了php中ftp_chdir与ftp_cdup函数用法。分享给大家供大家参考。具体用法如下:

ftp_chdir()函数

若成功,则返回 true,否则返回 false,如果切换目录失败,php还会发出一条警告.

语法:ftp_chdir(ftp_connection,directory)

参数 描述
ftp_connection 必需,规定要使用的 ftp 连接,ftp 连接的标识符.
directory 必需,规定要切换到的目录.

代码如下:

//设置基础连接
$conn_id=ftp_connect($ftp_server);
//用指定用户名密码登录到ftp服务器
$login_result=ftp_login($conn_id,$ftp_user_name,$ftp_user_pass);
//检查连接是否成功
if((!$conn_id)||(!$login_result))
{
  die("ftp connection has failed !");
}
echo "current directory:", ftp_pwd($conn_id),"n";
//执行切换目录操作
if(@ftp_chdir($conn_id,"somedir"))
{
  echo "current directory is now:", ftp_pwd($conn_id),"n";
}
else
{
  echo "couldn't change directoryn";
}
ftp_cdup($dir);         //执行切换目录操作
/*
ftp_cdup() 函数把当前目录改变为 ftp 服务器上的父目录。
//若成功,则返回 true。否则返回 false。
//语法
ftp_cdup(ftp_connection)

希望本文所述对大家的PHP程序设计有所帮助。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template