我需要一份FTP服务器上所有文件的列表。我可以使用php获取文件列表,但不知道如何获取文件大小。如何获取文件大小?谢谢。
发布于 2017-12-20 21:53:26
你可以打电话给
ftp_size如图所示
int ftp_size ( resource $ftp_stream , string $remote_file )通过FTP获取文件的大小。
例如:
$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服务器支持这一点。
https://stackoverflow.com/questions/47907564
复制相似问题