ftp_size()函数用于获取FTP服务器上特定文件的大小。
ftp_size(conn, myfile)
conn -FTP连接
myfile-服务器文件
ftp_size()函数返回成功后特定文件的大小(以字节为单位)。
以下是获取文件“ new.txt”大小的示例-
<?php
$ftp_server = "192.168.0.4";
$ftp_user = "username";
$ftp_pass = "gfhgfj236k";
$conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($con, $ftp_user, $ftp_pass);
$myfile = "new.txt";
//$file的大小
$size = ftp_size($conn, $myfile);
if ($size ! = -1) {
echo "Size is $fsize bytes";
} else {
echo "无法获取文件大小!";
}
//关闭
ftp_close($conn);
?>