php disk_total_space

后端 未结 5 1365
后悔当初
后悔当初 2021-01-21 11:04

i need help with disk_total_space function..

i have this on my code



        
5条回答
  •  后悔当初
    2021-01-21 11:29

    According to the docs for disk_total_space(), the value returned is for the filesystem the directory is located on. It doesn't count the space used in a directory + its subdirectories.

    You could shell out to du or for a more portable solution:

    $total = 0;
    
    foreach (new RecursiveDirectoryIterator($dir) as $entry)
    {
        if ($entry->isFile())
            $total += $entry->getSize();
    }
    

提交回复
热议问题