PHP FTP



PHP FTP Introduction

The FTP function provides client access to a file server through the File Transfer Protocol (FTP).

FTP functions are used to open, log in and close connections, as well as upload, download, rename, delete and obtain file information on the file server. Not all FTP functions work with every server or return the same results. Since PHP 3, FTP functions are available.

These functions are used for detailed access to the FTP server. If you only need to read and write to the FTP server, it is recommended to use the ftp:// wrapper in the Filesystem function.


Installation

The Windows version of PHP has built-in support for the FTP extension. There is no need to load any additional extension libraries to use the FTP functions.

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


PHP FTP function

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

##ftp_alloc() is required Allocate space for files uploaded to the FTP server. 5ftp_cdup()Change the current directory to the parent directory on the FTP server. 3ftp_chdir()Change the current directory on the FTP server. 3ftp_chmod()Set permissions on files via FTP. 5ftp_close()Close the FTP connection. 4ftp_connect()Open an FTP connection. 3ftp_delete()Delete a file on the FTP server. 3ftp_exec()Execute a program/command on the FTP server. 4ftp_fget()Download a file from the FTP server and save it to an open file locally. 3ftp_fput()Upload an already opened file and save it as a file on the FTP server. 3ftp_get_option()Returns various runtime options for the FTP connection. 4ftp_get()Download files from the FTP server. 3ftp_login()Log in to the FTP server. 3ftp_mdtm()Returns the last modification time of the specified file. 3ftp_mkdir()Create a new directory on the FTP server. 3ftp_nb_continue()Get/send files continuously. (Non-blocking) 4ftp_nb_fget()Download a file from the FTP server and save it to an already opened file locally. (Non-blocking) 4ftp_nb_fput()Upload an already opened file and save it as a file on the FTP server . (Non-blocking) 4ftp_nb_get()Download files from the FTP server. (Non-blocking) 4ftp_nb_put()Upload the file to the FTP server. (Non-blocking) 4ftp_nlist()Returns the file list in the specified directory on the FTP server. 3ftp_pasv()Set passive mode on or off. 3ftp_put()Upload the file to the FTP server. 3ftp_pwd()Returns the current directory name. 3ftp_quit() Alias ​​for ftp_close(). 3ftp_raw()Send a raw command to the FTP server. 5ftp_rawlist()Returns a detailed list of files in the specified directory. 3ftp_rename()Rename a file or directory on the FTP server. 3ftp_rmdir()Delete a directory on the FTP server.
FunctionDescriptionPHP
3
ftp_set_option() Set various runtime options for FTP connections. 4
ftp_site()Send the SITE command to the server. 3
ftp_size()Returns the size of the specified file. 3
ftp_ssl_connect()Open a secure SSL-FTP connection. 4
ftp_systype()Returns the system type identifier of the FTP server. 3


PHP FTP constant

PHP: Indicates that the constant is supported The earliest version of PHP.

##3 FTP_BINARY3FTP_IMAGE3FTP_TIMEOUT_SEC3##FTP_AUTOSEEKFTP_AUTORESUMEFTP_FAILEDFTP_FINISHEDFTP_MOREDATA
ConstantDescriptionPHP
FTP_ASCII
3
FTP_TEXT




4
Automatically determine resume and start locations for GET and PUT requests4
Asynchronous transfer failed4
Asynchronous transfer successful4
Asynchronous transfer is active4