简体   繁体   中英

How to get disk free space from sftp? PHP

Is there any way possible to get the free space of your sever's directory on 'php'?.

Like on laravel:

Storage::disk('sftp')->getAvailableStorage();

https://www.php.net/manual/en/function.disk-free-space.php

You can use the disk_free_space function that returned free space in bytes

I found it. I used this library. 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}'");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM