1. drupal
    1. 6
    2. 8
    3. 7
6 file_space_used($uid = NULL)
7 – 8 file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT)

Determine total disk space used by a single user or the whole filesystem.


$uid Optional. A user id, specifying NULL returns the total space used by all non-temporary files.

$status Optional. The file status to consider. The default is to only consider files in status FILE_STATUS_PERMANENT.

Return value

An integer containing the number of bytes used.

Related topics

▾ 2 functions call file_space_used()

FileSpaceUsedTest::testFileSpaceUsed in modules/simpletest/tests/file.test
Test different users with the default status.
file_validate_size in includes/
Check that the file's size is below certain limits.


includes/, line 1351

function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
  $query = db_select('file_managed', 'f');
  $query->condition('f.status', $status);
  $query->addExpression('SUM(f.filesize)', 'filesize');
  if (isset($uid)) {
    $query->condition('f.uid', $uid);
  return $query->execute()->fetchField();