Home > php教程 > php手册 > php ftp_delete 与ftp_size教程

php ftp_delete 与ftp_size教程

WBOY
Release: 2016-06-13 10:09:41
Original
1199 people have browsed it

本文章来讲一下php ftp_delete删除文件 与ftp_size获取文件的大小,下面我们分别来看看二个函数的实例吧。

本文章来讲一下php ftp_delete删除文件 与ftp_size获取文件的大小,下面我们分别来看看二个函数的实例吧。

$file = 'public_html/old.txt';
// 连接FTP服务器
$conn_id = ftp_connect($ftp_server);
// 验证用户名和密码
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// 删除指定文件
if (ftp_delete($conn_id, $file)) {
echo "$file 文件删除成功 n";
} else {
echo "删除 $file 文件失败n";
}
// 关闭FTP连接www.111cn.cn
ftp_close($conn_id);
?>

$file = 'somefile.txt';
// 连接FTP服务器
$conn_id = ftp_connect($ftp_server);
//验证用户名和密码
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
//获取指定文件的大小www.111cn.cn
$res = ftp_size($conn_id, $file);
if ($res != -1) {
    echo " $file 文件大小为 $res字节";
} else {
    echo "获取远程文件大小失败";
}
//关闭FTP连接
ftp_close($conn_id);
?> 

转载的朋友请注明来自www.111cn.cn

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template