PHP: www-filesize

To get the filesize of a file that isn’t located on your own server is not such
an easy thing! There’s this nice function in PHP to get the size of your files,
filesize() – but it just works for local files.

This workaround should work. – kinda slow, as you need to make a connection to the
remote host, but that’s probably the only way to do it:

sample usage:

I’ve written a full-featured static class which is able to determine the filesize of either a local file, a remote file or the recursive size of a local directory:
Use getSize() for byte retrieval and getSizeHuman() for human readable size strings.

sample usage:

Comments are closed