This article will talk about php ftp_delete to delete files and ftp_size to obtain the file size. Let’s take a look at examples of the two functions respectively.
This article will talk about php ftp_delete deleting files and ftp_size getting the file size. Let’s take a look at examples of the two functions respectively.
$file = 'public_html/old.txt';
// Connect to FTP server
$conn_id = ftp_connect($ftp_server);
// Verify username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// Delete the specified file
if (ftp_delete($conn_id, $file)) {
echo "$file file deleted successfully n";
} else {
echo "Failed to delete $file filen";
}
// Close FTP connection www.111cn.cn
ftp_close($conn_id);
?>
$file = 'somefile.txt';
// Connect to FTP server
$conn_id = ftp_connect($ftp_server);
//Verify username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
//Get the size of the specified file www.111cn.cn
$res = ftp_size($conn_id, $file);
if ($res != -1) {
echo "$file file size is $res bytes";
} else {
echo "Failed to obtain remote file size";
}
//Close FTP connection
ftp_close($conn_id);
?>
If you reprint, please indicate that it comes from www.111cn.cn