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.
Function | Description | PHP |
---|---|---|
is required Allocate space for files uploaded to the FTP server. | 5 | |
Change the current directory to the parent directory on the FTP server. | 3 | |
Change the current directory on the FTP server. | 3 | |
Set permissions on files via FTP. | 5 | |
Close the FTP connection. | 4 | |
Open an FTP connection. | 3 | |
Delete a file on the FTP server. | 3 | |
Execute a program/command on the FTP server. | 4 | |
Download a file from the FTP server and save it to an open file locally. | 3 | |
Upload an already opened file and save it as a file on the FTP server. | 3 | |
Returns various runtime options for the FTP connection. | 4 | |
Download files from the FTP server. | 3 | |
Log in to the FTP server. | 3 | |
Returns the last modification time of the specified file. | 3 | |
Create a new directory on the FTP server. | 3 | |
Get/send files continuously. (Non-blocking) | 4 | |
Download a file from the FTP server and save it to an already opened file locally. (Non-blocking) | 4 | |
Upload an already opened file and save it as a file on the FTP server . (Non-blocking) | 4 | |
Download files from the FTP server. (Non-blocking) | 4 | |
Upload the file to the FTP server. (Non-blocking) | 4 | |
Returns the file list in the specified directory on the FTP server. | 3 | |
Set passive mode on or off. | 3 | |
Upload the file to the FTP server. | 3 | |
Returns the current directory name. | 3 | |
Alias for ftp_close(). | 3 | |
Send a raw command to the FTP server. | 5 | |
Returns a detailed list of files in the specified directory. | 3 | |
Rename a file or directory on the FTP server. | 3 | |
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 FTP constant
PHP: Indicates that the constant is supported The earliest version of PHP.
Constant | Description | PHP |
---|---|---|
FTP_ASCII | 3 | |
FTP_TEXT | ||
4 | ||
Automatically determine resume and start locations for GET and PUT requests | 4 | |
Asynchronous transfer failed | 4 | |
Asynchronous transfer successful | 4 | |
Asynchronous transfer is active | 4 |