PHP Function Ftp_Delete - Delete Files Recursively From FTP Server
php function ftp_delete is an inbuilt function to delete files recursively from FTP server. It takes an ftp_connection instance as its parameter and the file path to delete as the argument. It returns true if it executes successfully or false if the error/warning is encountered during execution.
There are various situations when you have to connect and handle files from a ftp server. To do so you need to first get an access to the ftp server by using a ftp_connect function. Once connected you need to login and verify your credentials. After that you can perform various operations on the ftp file server like upload, download, rename and delete files. However there are some hidden difficulties when it comes to handling ftp files.
In order to list all the files in the ftp server there are two functions ftp_nlist and ftp_rawlist. The ftp_nlist returns a basic listing of files in the directory while the ftp_rawlist gives an advanced type of listing. The ftp_rawlist gives details like permission, user, group, size(in bits), last modified date(month, day, time), file name and type of the file.
After listing all the files in the ftp file server you need to choose a specific remote file for downloading to your local machine. To do so you can use the ftp_fget function. It takes an ftp_connection stream, the remote file path and an open file handler as arguments. The mode can be set to either FTP_ASCII or FTP_BINARY and the resumepos is used to decide at what position of the downloaded file the download should start.