有什么办法可以在"php"上获得服务器目录的可用空间吗?。
喜欢laravel:
Storage::disk('sftp')->getAvailableStorage();
https://www.php.net/manual/en/function.disk-free-space.php
您可以使用disk_free_space
函数,该函数返回以字节为单位的可用空间
我找到了它。我使用了这个库。https://github.com/phanan/remote
$config = json_decode($storage->config);
$connection = new Remote([
'host' => $config->host,
'port' => 22,
'username' => $config->username,
'password' => $config->password,
]);
$available_size = $connection->exec("df --block-size=1 /home | tail -1 | awk '{print $4}'");