echo $sftp->size('foldername');
This code only return the default size of directory 4096
How can i read the total size, used space of the directory/folder that contains many files?
Thanks a lot for your help!
echo $sftp->size('foldername');
This code only return the default size of directory 4096
How can i read the total size, used space of the directory/folder that contains many files?
Thanks a lot for your help!
To do this with SFTP I guess you could do something like this (untested):
$size = 0;
$files = $sftp->rawlist('foldername', true);
foreach ($files as $file) {
$size+= $file['size'];
}
Note that recursive directory listings with SFTP can be slow.
Alternatively, you could do $sftp->exec('du -s foldername');
. That'd be the fastest way. Since SFTP extends SSH2 with phpseclib exec
is a valid method.