当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP FTP

PHP
PHP 介绍
PHP 安装
PHP 语法
PHP 变量
PHP操作符
PHP If...Else
PHP Switch
PHP 数组
PHP 循环
PHP 函数
PHP 表单
PHP $_GET
PHP $_POST
PHP Date
PHP Include
PHP 文件处理
PHP 文件上传
PHP Cookies
PHP Sessions
PHP 发送邮件

PHP FTP


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 779 ::
收藏到网摘: n/a

PHP FTP Introduction
PHP的FTP介绍

The FTP functions give client access to file servers through the File Transfer Protocol (FTP).
FTP函数提供从客户端到服务器的标准文件传输协议(FTP)连接

The FTP functions are used to open, login and close connections, as well as upload, download, rename, delete, and get information on files from file servers. Not all of the FTP functions will work with every server or return the same results. The FTP functions became available with PHP 3.
FTP函数用于打开、登录、关闭连接,及上传、下载、重命名、删除、获取信息于服务器上的文件。并非所有的FTP函数适用于所有的服务器或返回相同结果。FTP函数自PHP3开始提供。

These functions are meant for detailed access to an FTP server. If you only wish to read from or write to a file on an FTP server, consider using the ftp:// wrapper with the Filesystem functions.
这些函数用于对 FTP 服务器进行广泛的控制。如果只想在一个 FTP 服务器上读写文件,考虑使用文件系统函数中的 ftp:// wrapper,它提供了简单和更直观的接口。


Installation
安装

The windows version of PHP has built-in support for the FTP extension. So, the FTP functions will work automatically.
PHP 的 Windows 版本已经内置该扩展模块的支持。无需加载任何附加扩展库即可使用这些函数。

However, if you are running the Linux version of PHP, you will have to compile PHP with --enable-ftp (PHP 4+) or --with-ftp (PHP 3) to get the FTP functions to work.
但要在Linux版本的PHP中使用本类函数,需要在编译 PHP 时加上 --enable-ftp (PHP 4+)或--with-ftp(PHP 3)。


PHP FTP Functions
PHP的FTP函数

PHP: indicates the earliest version of PHP that supports the function.
PHP:最早支持这些函数的PHP版本

Function
函数
Description
说明
PHP
ftp_alloc() Allocates space for a file to be uploaded to the FTP server
为上传文件分配空间
5
ftp_cdup() Changes the current directory to the parent directory on the FTP server
切换到当前目录的父目录
3
ftp_chdir() Changes the current directory on the FTP server
在 FTP 服务器上切换当前目录
3
ftp_chmod() Sets permissions on a file via FTP
通过FTP服务器设置一个文件特许[permission]
5
ftp_close() Closes an FTP connection
关闭一个活动的 FTP 连接
4
ftp_connect() Opens an FTP connection
建立一个新的 FTP 连接
3
ftp_delete() Deletes a file on the FTP server
删除 FTP 服务器上的一个文件
3
ftp_exec() Executes a program/command on the FTP server
请求运行一条 FTP 命令
4
ftp_fget() Downloads a file from the FTP server and saves it to an open file
从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中
3
ftp_fput() Uploads from an open file and saves it to a file on the FTP server
上传一个已经打开的文件到 FTP 服务器
3
ftp_get_option() Returns runtime behaviors of the FTP connection
返回当前 FTP 连接的各种不同的选项设置
4
ftp_get() Downloads a file from the FTP server
从 FTP 服务器上下载一个文件
3
ftp_login() Logs on to an FTP connection
登录 FTP 服务器
3
ftp_mdtm() Returns the last modified time of a specified file
返回指定文件的最后修改时间
3
ftp_mkdir() Creates a new directory on the FTP server
建立新目录
3
ftp_nb_continue() Continues retrieving/sending a file (non-blocking)
连续获取/发送文件(non-blocking)
4
ftp_nb_fget() Downloads a file from the FTP server and saves it to an open file (non-blocking)
从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中 (non-blocking)
4
ftp_nb_fput() Uploads from an open file and saves it to a file on the FTP server (non-blocking)
上传一个已经打开的文件到 FTP 服务器 (non-blocking)
4
ftp_nb_get() Downloads a file from the FTP server (non-blocking)
从 FTP 服务器上下载一个文件 (non-blocking)
4
ftp_nb_put() Uploads a file to the FTP server (non-blocking)
将一个本地文件上传至 FTP 服务器(non-blocking)
4
ftp_nlist() Lists the files in a specified directory on the FTP server
返回给定目录的文件列表
3
ftp_pasv() Turns passive mode on or off
返回当前 FTP 被动模式是否打开
3
ftp_put() Uploads a file to the FTP server
上传文件到 FTP 服务器
3
ftp_pwd() Returns the current directory name
返回当前目录名
3
ftp_quit() Alias of ftp_close()
ftp_close() 的别名
3
ftp_raw() Sends a raw command to the FTP server
发送原始FTP命令到服务器
5
ftp_rawlist() Returns a detailed list of files in the specified directory
返回指定目录下文件的详细列表
3
ftp_rename() Renames a file or directory on the FTP server
更改 FTP 服务器上指定的文件名
3
ftp_rmdir() Removes a directory on the FTP server
删除一个目录
3
ftp_set_option() Sets runtime options for the FTP connection
设置各种 FTP 连接运行时选项
4
ftp_site() Sends a SITE command to the server
向服务器发送 SITE 命令
3
ftp_size() Returns the size of the specified file
返回指定文件的大小
3
ftp_ssl_connect() Opens a secure SSL-FTP connection
打开一个安全的 SSL-FTP连接
4
ftp_systype() Returns the system type identifier of the FTP server
返回远程 FTP 服务器的系统类型
3


PHP FTP Constants
PHP的FTP常量

PHP: indicates the earliest version of PHP that supports the constant.
PHP:最早支持这些常数的PHP版本

Constant
常量
Description
说明
PHP
FTP_ASCII   3
FTP_TEXT   3
FTP_BINARY   3
FTP_IMAGE   3
FTP_TIMEOUT_SEC   3
FTP_AUTOSEEK   4
FTP_AUTORESUME Determine resume position and start position for get and put requests automatically
为 GET 和 PUT 请求自动决定恢复和开始的位置 (只能工作在 FTP_AUTOSEEK 打开的情况下)
4
FTP_FAILED Asynchronous transfer has failed
异步传输失败
4
FTP_FINISHED Asynchronous transfer has finished
异步传输成功
4
FTP_MOREDATA Asynchronous transfer is still active
异步传输是活动状态的
4

评论 (0) All

登陆 | 还没注册?