ftp_size
(PHP 4, PHP 5)
ftp_size — 返回指定文件的大小
<h3>说明</h3>
 int <strong>ftp_size</strong>
  ( resource <code>$ftp_stream</code>
 , string <code>$remote_file</code>
 )
<p>
 <strong>ftp_size()</strong> 函数以字节返回远程文件
 <code>remote_file</code> 的大小。如果指定文件不存在或发生错误,则返回
 -1。有些 FTP 服务器可能不支持此特性。
</p>
<p><strong>Note</strong>:
 <p>
  获取成功返回文件大小,否则返回 -1。
 </p>
</p>
<h3>参数</h3>
<p>ftp_stream
FTP 连接资源。
remote_file
远程文件。
</p>返回值
执行成功返回文件大小,失败返回 -1。
<h3>范例</h3>
 <p>
  <p><strong>Example #1 <strong>ftp_size()</strong> 例子</strong></p><?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);
?>
</p>参见
ftp_rawlist() - 返回指定目录下文件的详细列表