Getting the Size of a File

Problem

You want to know what the size of a file is.

Solution

Use the File::size() method.

$bytes = File::size($filename);

Discussion

Watch out for errors.

If you try to get the type of non-existent files or files you don't have access to, errors will occur.

comments powered by Disqus