FTP ftp_size

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_size — 주어진 파일의 크기를 반환


설명

ftp_size(FTP\Connection $ftp, string &$filename): int

ftp_size()는 주어진 파일의 크기를 바이트 단위로 반환합니다.

메모: 모든 서버가 이 기능을 지원하는 것은 아닙니다.


매개변수

ftp
FTP\Connection 인스턴스입니다.
filename
원격 파일입니다.

반환 값

성공 시 파일 크기를 반환하고 오류 시 -1을 반환합니다.


변경 로그

버전 설명
8.1.0 ftp 매개변수는 이제 FTP\Connection 인스턴스를 필요로 합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 ftp_size() 예제

                  
<?php

$file = 'somefile.txt';

// set up basic connection
$ftp = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

// get the size of $file
$res = ftp_size($ftp, $file);

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

// close the connection
ftp_close($ftp);

?>
                  
                

기타

  • ftp_rawlist() - 지정된 디렉토리에 있는 파일의 자세한 목록을 반환합니다.