FTP 서버의 모든 파일 목록이 필요합니다. PHP를 사용하여 파일 목록을 얻을 수는 있지만 파일 크기를 얻는 방법은 알 수 없습니다. 파일 크기를 어떻게 얻습니까? 감사.PHP를 사용하여 FTP 서버에서 파일 크기를 가져 오는 방법은 무엇입니까?
-1
A
답변
0
당신은 FTP를 통해 파일의 크기를 얻으려면
int ftp_size (resource $ftp_stream , string $remote_file)
에서
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 connection
ftp_close($conn_id);
그러나 일부 FTP 서버는이 기능을 지원.
의
+0
일부 파일의 크기, 동일한 구문을 확인하는 경우? –
+1
원본 링크의 예제를 사용하여 내 대답을 편집했습니다.이 예제는 실제 예제에서 사용하는 방법에 대해 자세히 설명합니다. – mquinn
가능한 복제 [FTP 서버에서 파일의 파일 크기를 얻는 방법?] (https://stackoverflow.com/questions/3211290/how-to-get-file-size-of -files-on-ftp-server) – dferenc
http://php.net/manual/en/function.filesize.php – Randy