首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ftp_size

(PHP 4, PHP 5, PHP 7)

ftp_size - 返回给定文件的大小

描述

代码语言:javascript
复制
int ftp_size ( resource $ftp_stream , string $remote_file )

ftp_size()以字节为单位返回给定文件的大小。

注意:并非所有服务器都支持此功能。

参数

ftp_stream

FTP连接的链接标识符。

remote_file

远程文件。

Return Values

成功时返回文件大小,错误时返回-1。

例子

示例#1 ftp_size()示例

代码语言:javascript
复制
<?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 connection
ftp_close($conn_id);

?>

扫码关注腾讯云开发者

领取腾讯云代金券