导航首页 » 技术教程 » PHP:ftp_size()的用法_FTP函数
PHP:ftp_size()的用法_FTP函数 173 2023-12-18   

ftp_size

(PHP 4, PHP 5)

ftp_size — 返回指定文件的大小

说明

int ftp_size ( resource $ftp_stream , string $remote_file )

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

Note:

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

参数

ftp_stream

FTP 连接资源。

remote_file

远程文件。

返回值

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

范例

Example #1 ftp_size() 例子

$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);
?>

参见

ftp_rawlist() - 返回指定目录下文件的详细列表


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103