search
Homephp教程php手册php中ftp_chdir与ftp_cdup函数用法

这篇文章主要介绍了php中ftp_chdir与ftp_cdup函数用法,以实例形式讲述了PHP中的FTP目录操作技巧,具有一定的借鉴价值,需要的朋友可以参考下

本文实例讲述了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程序设计有所帮助。

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function