Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

PHP FTP function


May 11, 2021 PHP


Table of contents


PHP FTP function

This section focuses on FTP-related functions in PHP and explains how php operates ftp connections, transfers, and files and directories-related operations.


Introduction to PHP FTP

The FTP function provides client access to the file server through a file transfer protocol (FTP).

The FTP function is used to open, log on, and close connections, as well as to upload, download, rename, delete, and obtain file information on the file server. N ot all FTP functions work for each server or return the same results. FTP functions are available as of PHP 3.

These functions are used for detailed access to the FTP server. If you only need to read and write to the FTP server, we recommend that you use the ftp:// fileystem function.


Installation

PhP's version of Windows has built-in support for FTP extensions. Y ou don't need to load any additional extension libraries to use FTP functions.

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


PHP FTP function

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

function describe PHP
ftp_alloc() For the file allocation space 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() Use the permissions on the FTP settings file. 5
ftp_close() Turn off the FTP connection. 4
ftp_connect() Open the FTP connection. 3
ftp_delete() Delete a file on the FTP server. 3
ftp_exec() Perform a program / command on the FTP server. 4
ftp_fget() Download a file from the FTP server and save it to a localized file. 3
ftp_fput() Upload an open file and save it as a file on the FTP server. 3
ftp_get_option() Returns the various runtime options for the FTP connection. 4
ftp_get() Download files from the 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() Continuous acquisition / send files.(No blocking) 4
ftp_nb_fget() Download a file from the FTP server and save it to a localized file.(No blocking) 4
ftp_nb_fput() Upload an open file and save it as a file on the FTP server.(No blocking) 4
ftp_nb_get() Download files from the FTP server.(No blocking) 4
ftp_nb_put() Upload the file to the FTP server.(No blocking) 4
ftp_nlist() Returns a list of files that specify the directory on the FTP server. 3
ftp_pasv() Set the passive mode to turn it on or off. 3
ftp_put() Upload the file to the FTP server. 3
ftp_pwd() Returns the current directory name. 3
ftp_quit() FTP_Close () alias. 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 the files or directories on the FTP server. 3
ftp_rmdir() Delete a directory on the FTP server. 3
ftp_set_option() Set various runtime options for the FTP connection. 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 the earliest version of PHP 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 the restore and start position for GET and PUT requests 4
FTP_FAILED Asynchronous transmission failed 4
FTP_FINISHED Asynchronous transmission is successful 4
FTP_MOREDATA Asynchronous transmission is active 4

That's the whole story of this section, and in the next section, we'll cover HTTP functions.