WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP 5 FTP Functions



Introduction to PHP FTP

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. They are also used to upload, download, rename, delete, and obtain file information on the file server. Not all FTP functions work for every server or return the same results. As of 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 ftp: //wrapper in the Filesystem function.


Installation

The Windows version of PHP has built-in support for FTP extensions. You do not need to load any additional extension libraries to use FTP functions.

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


PHP 5 FTP Functions

function description PHP
ftp_alloc () Allocate space for files to upload 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 the file 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 open file locally. 3
ftp_fput () Upload an 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 a file from an 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 () Retrieve /send files continuously. (Non-blocking) 4
ftp_nb_fget () Download a file from the FTP server and save it to an open file locally. (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 an FTP server. (Non-blocking) 4
ftp_nb_put () Upload the file to an FTP server. (Non-blocking) 4
ftp_nlist () Returns the file list of the specified directory on the FTP server. 3
ftp_pasv () Set passive mode to on or off. 3
ftp_put () Upload the file to an 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 list 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 () 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 constants

PHP : Indicates the earliest PHP version that supports this 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 Automatically decide where to resume and start for GET and PUT requests 4
FTP_FAILED Asynchronous transmission failed 4
FTP_FINISHED Successful asynchronous transmission 4
FTP_MOREDATA Asynchronous transmission is active 4