PHP FTP function Using tutorial
The introduction of PHP FTP
This feature provides FTP clients access to file servers through File Transfer Protocol (FTP).
The FTP function is used to open, login and close contact, as well as upload, download, rename, delete and get information files from the file server. Not all FTP features will be returned with each server or return the same results. The FTP function becomes available with PHP 3.
These features are for detailed access to the FTP server. If you only want to read or write files on the FTP server, you can consider using the wrapper ftp://with the file's functionality.
Installation
The PHP version of Windows has built-in support for FTP extensions. Therefore, the FTP function will work automatically.
However, if you are running a Linux version of PHP, you will have to work with the F T P function that compiles PHP-enabled-f TP (P HP4 +) or-WI th-f t P (P H P3).
FTP Functions for PHP
PHP: Displays the earliest PHP version, supported features.
| Function |
Description |
PHP |
| Ftp_alloc () |
Allocates space for a file to being uploaded to the FTP server |
5 |
| Ftp_cdup () |
Changes the current directory to the parent directory on the FTP server |
3 |
| Ftp_chdir () |
Changes the current directory on the FTP server |
3 |
| Ftp_chmod () |
Sets permissions on a file via FTP |
5 |
| Ftp_close () |
Closes an FTP connection |
4 |
| Ftp_connect () |
Opens an FTP connection |
3 |
| Ftp_delete () |
Deletes a file on the FTP server |
3 |
| Ftp_exec () |
Executes a program/command on the FTP server |
4 |
| Ftp_fget () |
Downloads a file from the FTP server and saves it to an open file |
3 |
| Ftp_fput () |
Uploads from an open file and saves it to a file on the FTP server |
3 |
| Ftp_get_option () |
Returns runtime behaviors of the FTP connection |
4 |
| Ftp_get () |
Downloads a file from the FTP server |
3 |
| Ftp_login () |
Logs on to an FTP connection |
3 |
| Ftp_mdtm () |
Returns the last modified time of a specified file |
3 |
| Ftp_mkdir () |
Creates a new directory on the FTP server |
3 |
| Ftp_nb_continue () |
Continues retrieving/sending a file (non-blocking) |
4 |
| Ftp_nb_fget () |
Downloads a file from the FTP server and saves it to an open file (non-blocking) |
4 |
| Ftp_nb_fput () |
Uploads from an open file and saves it to a file on the FTP server (non-blocking) |
4 |
| Ftp_nb_get () |
Downloads a file from the FTP server (non-blocking) |
4 |
| Ftp_nb_put () |
Uploads a file to the FTP server (non-blocking) |
4 |
| Ftp_nlist () |
Lists the files in a specified directory on the FTP server |
3 |
| FTP_PASV () |
Turns passive mode on or off |
3 |
| Ftp_put () |
Uploads a file to the FTP server |
3 |
| Ftp_pwd () |
Returns the current directory name |
3 |
| Ftp_quit () |
Alias of Ftp_close () |
3 |
| Ftp_raw () |
Sends a raw command to the FTP server |
5 |
| Ftp_rawlist () |
Returns a detailed list of files in the specified directory |
3 |
| Ftp_rename () |
Renames a file or directory on the FTP server |
3 |
| Ftp_rmdir () |
Removes a directory on the FTP server |
3 |
| Ftp_set_option () |
Sets runtime options for the FTP connection |
4 |
| Ftp_site () |
Sends a SITE command to the server |
3 |
| Ftp_size () |
Returns the size of the specified file |
3 |
| Ftp_ssl_connect () |
Opens a secure ssl-ftp connection |
4 |
| Ftp_systype () |
Returns the system type identifier of the FTP server |
3 |
PHP FTP Constants
php: Indicates the earliest version of PHP that supports the constant.
| Constant |
Description |
PHP |
| Ftp_ascii |
|
3 |
| Ftp_text |
|
3 |
| Ftp_binary |
|
3 |
| Ftp_image |
|
3 |
| Ftp_timeout_sec |
|
3 |
| Ftp_autoseek |
|
4 |
| Ftp_autoresume |
Determine resume position and start position for get and put requests automatically |
4 |
| Ftp_failed |
Asynchronous transfer has failed |
4 |
| Ftp_finished |
Asynchronous transfer has finished |
4 |
| Ftp_moredata |
Asynchronous transfer is still active |
4 |
http://www.bkjia.com/PHPjc/630491.html www.bkjia.com true http://www.bkjia.com/PHPjc/630491.html techarticle PHP ftp function using the tutorial introduced PHP FTP This feature provides FTP client access to file server via File Transfer Protocol (FTP). The FTP function is used to open, login name and secret ...