如何在PHP中获取Web服务器的可用空间?

Ami*_*mar 5 php

我有一个像'mydomain.com'这样的域名.我想在php的帮助下检查服务器上有多少可用空间.喜欢我们的硬盘我们use disk_total_space("C:");.任何人都可以帮我解决问题.

Pet*_*erJ 11

根据文件系统的结构,您可以对Linux主机使用以下内容:

$df = round(disk_free_space("/var/www") / 1024 / 1024 / 1024);
print("Free space: $df GB");
Run Code Online (Sandbox Code Playgroud)

或者在你的情况下,它听起来像你在Windows上运行所以:

$df = round(disk_free_space("C:") / 1024 / 1024 / 1024);
print("Free space: $df GB");
Run Code Online (Sandbox Code Playgroud)


小智 5

用于获取可用空间的主要功能与上述相同.你必须使用disk_free_space().但不同的是知道服务器路径.把它放在括号里.