Is it possible to get special information about a local disk with PHP?

I am running my PHP code on my local computer. Therefore, I just want to know that PHP has any functions for retrieving local hard drive information. Same as disk name, disk space, .etc free space.

Many thanks!

+2
source share
4 answers

In addition, yes, you can get this information because you can execute commands. For disk information, there are several PHP functions, check the following links:

Retrieving the drive name, however, must be done using the command. I just booted Windows into VirtualBox, and the following seems to work:

if( preg_match( '~Volumenaam : (.*)~i', `fsutil fsinfo volumeinfo C:\\`, $matches ) ) { echo $matches[1]; } 

Volumenaam is Dutch for "Volumename". I have only the Dutch version of Windows, so you will need to check what the actual string is.

Good luck.

+1
source

Built-in Commands:

If you need more, you can access local commands through system() .

To use the disk, you will also find various fragments on the network, for example. this is:

+4
source

There are two functions: disk_free_space() and disk_total_space() .

+2
source

Have you tried finding a PHP manual before offering here?

These two functions came up very quickly for me:

Other data, such as a drive name, may be more complex (you might need to use system() as per the other answer here), but this should give you a start.

However, note that when PHP runs on a website, it will have quite a few restrictions on what it can do; it will probably be limited to its local web folders for any disk access.

0
source

All Articles