Hàm ftp_size() lấy kích thước của một tập tin cụ thể trên máy chủ FTP.
Cú pháp
ftp_size($conn, $myfile)
Tham số
conn – Kết nối FTP.
myfile – Tập tin trên máy chủ.
Giá trị trả về
Hàm trả về kích thước tập tin tính bằng byte nếu thành công, -1 nếu lỗi.
Ví dụ
<?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($conn, $ftp_user, $ftp_pass);
$myfile = "new.txt";
$size = ftp_size($conn, $myfile);
if ($size != -1) {
echo "Size is $size bytes";
} else {
echo "Cannot get the file size!";
}
ftp_close($conn);
?>