Search code examples
phpremovable-storage

php get free space of a removable media (eg. USB Flash Drive)


Title says it all, I tried disk_free_space(), but it is not working for me. I guess it only returns "disk space" and not just any random media.

I have a script that would create another file in the removable drive, and a simple check for free space would definitely be helpful.


Solution

  • You can try diskfreespace() function. It returns the free space, in bytes, of the specified directory. This function is an alias of the disk_free_space() function.