The ftp_delete() function is used to delete a file on the FTP server.
Syntax
ftp_delete(con,myfile);
Parameters
con − The FTP connection
myfile − The file to be deleted
Return
The ftp_delete() function returns TRUE on success or FALSE on failure
Example
The following is an example to delete a file −
<?php
$ftp_server="192.168.0.4";
$ftp_user="amit";
$ftp_pass="tywg61gh";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$myfile = "E:/new/demo.txt";
if (ftp_delete($con, $myfile)) {
echo "The file deleted!";
} else {
echo "The file cannot be deleted!";
}
ftp_close($con);
?>