【问题标题】:php disk_total_space() minus disk_free_space() does not equal occupied spacephp disk_total_space() 减去 disk_free_space() 不等于占用空间
【发布时间】:2013-05-22 15:13:12
【问题描述】:

我想检查存储上的可用空间,我正在存储用户的附件。我选择了disk_free_space()disk_total_space()。结果是:

可用空间:5.47 GB
总空间:5.86 GB

所以占用的空间 = 0.39 GB

我还使用filesize() 遍历文件以捕捉它们的大小。这些文件总共占用 18.34 GB。 (最大文件大小为 4 MB,因此 PHP 手册中关于 2GB 的注释适用)

所以:

总空间 - 可用空间 != 占用空间

为什么?

文件系统在 HP-UX 上。我使用同一个帐户测量了所有值 - 我从 php 脚本运行所有命令,通过 Internet 浏览器执行脚本。

我还检查了 Windows 中的功能。结果还可以。

我遇到了一些与函数相关的其他问题(How to get the disk space on a server?How to determin how much space is freeon your server? (php)How to detect the server space enough for the uploaded file or no?How to get the disk space on a server?Is it possible to get special Local Disk information from PHP?php disk_total_space),但没有找到答案。

【问题讨论】:

  • 我觉得Ur系统有一些分区,试试disk_free_space('/home/')和disk_total_space('/home/')
  • @Sergey 谢谢。他们都返回了0

标签: php filesystems size hp-ux


【解决方案1】:

取决于操作系统和使用的文件系统,这在很大程度上取决于您调用函数的目录。原因是,Linux 将几个驱动器安装到一棵大树中。您不能只调用disk_total_space('/'),因为这只会为您提供根分区的大小。试试disk_total_space($attachmentFolder);

【讨论】:

  • 完美。谢谢!我试图在 PHP 手册中找到与操作系统相关的信息和提示,但没有成功。我错过了吗?你能提供一个我可以了解更多信息的来源吗?
  • 很难说 ^^ 这就是基于 *NIX 的操作系统组织文件系统的方式(就像在一棵树中提到的那样)。发生的一个问题是,并非每个“文件系统”都是“真实的”。有一些虚拟文件系统,比如用于设备的文件系统(通常是/dev)或进程(/proc),它们根本没有大小(或无限大,取决于观点)。这意味着,如果一个与 FS 相关的操作总是影响到每个挂载的文件系统,它可能结束得不是很好......因此,不知道,也许 man mount linux.die.net/man/8/mount 作为源?)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-04
  • 1970-01-01
  • 1970-01-01
  • 2011-07-24
  • 1970-01-01
  • 2017-12-24
  • 2010-09-22
相关资源
最近更新 更多