Home  >  Article  >  Backend Development  >  php ftp_delete and ftp_size tutorial_PHP tutorial

php ftp_delete and ftp_size tutorial_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:06:56962browse

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630482.htmlTechArticleThis article talks about php ftp_delete to delete files and ftp_size to get the file size. Let’s take a look at the two separately. An instance of the function. This article will talk about php ftp_delete to delete files...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn