You can use the df command in PHP to get the amount of free disk space available in a Linux or Unix-based system. This command returns an array containing information about the current disk usage of each mounted file system.
Here is an example of how to use the df command in PHP to get the amount of free disk space on the root partition:
main.php130 chars7 linesThis code prints the amount of free disk space on the root partition in a human-readable format (e.g. "50G"). If you want to get the free space in bytes, you can modify the df command to use the -B option and parse the output accordingly:
main.php145 chars7 linesNote that using shell commands in PHP can pose security risks if not done carefully, so make sure to sanitize any user input before using it in the shell_exec function.
gistlibby LogSnag