PHP FTP-funktioner

PHP FTP-introduktion

FTP-funktioner tillhandahåller klientåtkomst till filserver via filöverföringsprotokollet (FTP).

FTP-funktioner används för att öppna, logga in och stänga anslutningar, samt för att ladda upp, ladda ner, döpa om, ta bort och få filinformation från filservern. inte alla FTP-funktioner fungerar på varje server eller returnerar samma resultat. FTP-funktioner har varit tillgängliga sedan PHP 3.

Dessa funktioner används för att utföra detaljerad åtkomst till FTP-server. Om du bara behöver utföra läs- och skrivoperationer på FTP-servern, rekommenderas det att använda ftp://-omslaget i Filesystem-funktionen.

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 (PHP4 or above version) or --with-ftp (PHP3 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 the FTP using 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 modified time of the specified file. 3
ftp_mkdir() Create a new directory on the FTP server. 3
ftp_nb_continue() Continuous file retrieval/send (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 if the current FTP passive mode is enabled. 3
ftp_put() 将文件上传到服务器。 3
ftp_pwd() 返回当前目录名称。 3
ftp_quit() ftp_close() 的别名。 3
ftp_raw() 向 FTP 服务器发送一个原始命令。 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