The FTP function provides client access to a file server through 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. As of PHP 3, FTP functions are available.
These functions are used to provide granular access to the FTP server. If you only need to perform read and write operations on the FTP server, it is recommended to use the ftp:// wrapper in the Filesystem function.
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, add the --enable-ftp option (PHP4 or above) or the --with-ftp option (PHP3 version) when compiling PHP.
PHP : Indicates the earliest PHP version that supports this function.
function | describe | PHP |
---|---|---|
ftp_alloc() | Allocate space for files 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 permissions on files via 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 the FTP server. | 4 |
ftp_fget() | Download a file from the FTP server and save it to an already open file locally. | 3 |
ftp_fput() | Upload an already open file and save it as a file on the FTP server. | 3 |
ftp_get_option() | Returns various runtime options for FTP connections. | 4 |
ftp_get() | Download files from FTP server. | 3 |
ftp_login() | Log in to the FTP server. | 3 |
ftp_mdtm() | Returns the last modification time of the specified file. | 3 |
ftp_mkdir() | Create a new directory on the FTP server. | 3 |
ftp_nb_continue() | Get/send files continuously. (no blocking) | 4 |
ftp_nb_fget() | Download a file from the FTP server and save it to an already open file locally. (no blocking) | 4 |
ftp_nb_fput() | Upload an already open file and save it as a file on the FTP server. (no blocking) | 4 |
ftp_nb_get() | Download files from FTP server. (no blocking) | 4 |
ftp_nb_put() | Upload the file to the FTP server. (no blocking) | 4 |
ftp_nlist() | Returns the file list in the specified directory on the FTP server. | 3 |
ftp_pasv() | Set passive mode on or off. | 3 |
ftp_put() | Upload the file to the FTP server. | 3 |
ftp_pwd() | Returns the current directory name. | 3 |
ftp_quit() | Alias for ftp_close(). | 3 |
ftp_raw() | Send a raw command to the FTP server. | 5 |
ftp_rawlist() | Returns a detailed listing of files in the specified directory. | 3 |
ftp_rename() | Rename a file or directory on the FTP server. | 3 |
ftp_rmdir() | Delete a directory on the FTP server. | 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 : Indicates the earliest PHP version that supports this constant.
constant | describe | PHP |
---|---|---|
FTP_ASCII | 3 | |
FTP_TEXT | 3 | |
FTP_BINARY | 3 | |
FTP_IMAGE | 3 | |
FTP_TIMEOUT_SEC | 3 | |
FTP_AUTOSEEK | 4 | |
FTP_AUTORESUME | Automatically determine where to resume and start for GET and PUT requests | 4 |
FTP_FAILED | Asynchronous transfer failed | 4 |
FTP_FINISHED | Asynchronous transfer successful | 4 |
FTP_MOREDATA | Asynchronous transfers are active | 4 |