PHP: ftp_delete() function
Description
The ftp_delete() function is used to delete a file on the FTP server.
Version:
(PHP 4 and above)
Syntax:
ftp_delete(ftp_connection, file_name)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
ftp_connection | The link identifier of the FTP connection. | Required | Resource |
file_name | The file to delete. | Required | String |
Return value:
TRUE on success or FALSE on failure.
Value Type: Boolean.
Example:
<?php
$ftp_server="192.168.0.2";
$ftp_user_name="abc123";
$ftp_user_pass="abc123";
$file = 'D:/ds/abc123.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to delete $file
if (ftp_delete($conn_id, $file)) {
echo $file."deleted successful\n";
} else {
echo "could not delete".$file;
}
// close the connection
ftp_close($conn_id);
?>
Output:
could not delete D:/ds/abc123.txt
See also
Previous: ftp_connect
Next: ftp_exec
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/ftp_delete.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics