ftp_size

(PHP 4, PHP 5, PHP 7)

ftp_size返回指定文件的大小

说明

ftp_size ( resource $ftp_stream , string $remote_file ) : int

ftp_size() 函数以字节返回远程文件 remote_file 的大小。如果指定文件不存在或发生错误,则返回 -1。有些 FTP 服务器可能不支持此特性。

Note:

获取成功返回文件大小,否则返回 -1。

参数

ftp_stream

FTP 连接资源。

remote_file

远程文件。

返回值

执行成功返回文件大小,失败返回 -1。

范例

Example #1 ftp_size() 例子

<?php
$file 
'somefile.txt';

// set up basic connection 
$conn_id ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// get the size of $file
$res ftp_size($conn_id$file);

if (
$res != -1) {
    echo 
"size of $file is $res bytes";
} else {
    echo 
"couldn't get the size";
}

//close the conntion
ftp_close($conn_id);
?>

参见