folder size

Discussion in 'PHP' started by promotingspace.net, Feb 1, 2008.

  1. #1
    Hi
    I know how to get an uploaded file size. but how can i measure the size of a folder and all of its contents it has inside?
    thanks
     
    promotingspace.net, Feb 1, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    $path = 'path/to/folder/*';
    
    $files = glob($path);
    $size = array_sum(array_map('filesize', $files));
    
    echo $size, ' bytes';
    
    PHP:
     
    nico_swd, Feb 1, 2008 IP