PHP FTP funktioner

PHP FTP-introduktion

FTP-funktioner giver klientadgang til filservere via filoverførselsprotokollen (FTP).

FTP-funktioner bruges til at åbne, logge ind og lukke forbindelser, samt til at uploade, downloade, omdøbe, slette og få filinformation fra filserveren. Ikke alle FTP-funktioner virker på hver server eller returnerer de samme resultater. FTP-funktioner har været tilgængelige siden PHP 3.

Disse funktioner bruges til at udføre detaljeret adgang til FTP-servere. Hvis du kun har brug for at udføre læse/skrive-operationer på FTP-servere, anbefales det at bruge ftp:// wrapper i Filesystem-funktionerne.

Install

The Windows version of PHP has built-in support for the FTP extension module. These functions can be used without loading any additional extension libraries.

However, if you are running a PHP Linux version, please add the --enable-ftp option (PHP 4 or above) or --with-ftp (PHP 3 version) when compiling.

PHP FTP funktioner

PHP:Indicate the earliest PHP version that supports this function.

Function 描述 PHP
ftp_alloc() Allocate space for the file to be uploaded to the FTP server. 5
ftp_cdup() Change the current directory to the parent directory on the FTP server. 3
ftp_chdir() Change the current directory on the FTP server. 3
ftp_chmod() Set file permissions on FTP through FTP. 5
ftp_close() Close the FTP connection. 4
ftp_connect() Open an FTP connection. 3
ftp_delete() Delete a file on the FTP server. 3
ftp_exec() Execute a program/command on FTP. 4
ftp_fget() Download a file from the FTP server and save it to a locally opened file. 3
ftp_fput() Upload an open file and save it as a file on the FTP server. 3
ftp_get_option() Return various different option settings of the current FTP connection. 4
ftp_get() Download a file from the FTP server. 3
ftp_login() Log in to the FTP server. 3
ftp_mdtm() Return the last modification time of the specified file. 3
ftp_mkdir() Create a new directory on the FTP server. 3
ftp_nb_continue() Continuous file retrieval/sending (non-blocking). 4
ftp_nb_fget() Download a file from the FTP server and save it to a locally opened file (non-blocking). 4
ftp_nb_fput() Upload an open file and save it as a file on the FTP server (non-blocking). 4
ftp_nb_get() Download a file from the FTP server (non-blocking). 4
ftp_nb_put() Upload a file to the server (non-blocking). 4
ftp_nlist() Return the file list of the specified directory. 3
ftp_pasv() Return whether the current FTP passive mode is enabled. 3
ftp_put() 把文件上传到服务器。 3
ftp_pwd() 返回当前目录名称。 3
ftp_quit() ftp_close() 的别名。 3
ftp_raw() 向 FTP 服务器发送一个 raw 命令。 5
ftp_rawlist() 返回指定目录中文件的详细列表。 3
ftp_rename() 重命名 FTP 服务器上的文件或目录。 3
ftp_rmdir() 删除 FTP 服务器上的目录。 3
ftp_set_option() 设置各种 FTP 运行时选项。 4
ftp_site() 向服务器发送 SITE 命令。 3
ftp_size() 返回指定文件的大小。 3
ftp_ssl_connect() 打开一个安全的 SSL-FTP 连接。 4
ftp_systype() 返回远程 FTP 服务器的系统类型标识符。 3

PHP FTP 常量

PHP:指示支持该常量的最早的 PHP 版本。

常量 描述 PHP
FTP_ASCII   3
FTP_TEXT   3
FTP_BINARY   3
FTP_IMAGE   3
FTP_TIMEOUT_SEC   3
FTP_AUTOSEEK   4
FTP_AUTORESUME

为 GET 和 PUT 请求自动决定恢复和开始的位置

只能工作在 FTP_AUTOSEEK 打开的情况下

4
FTP_FAILED 异步传输失败 4
FTP_FINISHED 异步传输成功 4
FTP_MOREDATA 异步传输是活动状态的 4