Getting size of FTP directory via PHP from remote server
$10-15 USD
Completed
Posted about 10 years ago
$10-15 USD
Paid on delivery
Hi
I want to figure out a way to get FTP directory size via php from remote server
I am using this PHP script to calculate folder size in same account which runs the script but this is not working for remote FTP account folder
$pathx = "/home/user/public_html/xfolder";
function filesize_recursive($pathx){
if(is_file($pathx)) return filesize($pathx);
$totalSize = 0;
foreach(glob($pathx."/*") as $fn)
$totalSize += filesize_recursive($fn);
return $totalSize;
}
I believe we can combine both the above script with the following
function getRecDirSize ($connection, $dir){
$temp = ftp_rawlist ($connection, "-alR $dir");
foreach ($temp as $file){
if (ereg ("([-d][rwxst-]+).* ([0-9]) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)", $file, $regs)){
$isdir = (substr ($regs[1],0,1) == "d");
if (!$isdir)
$size += $regs[5];
}
}
return $size;
}
Let see who can get folder site of FTP account
hi,
my name is shahid, i am working in web development from past four year. Surely will provide you quality work and we will have long term relationship in web development. let me know if i can help you. thanks
Looks easy for me.
Please contact me through your pm, Thanks.
################################################################################################################