Displaying the filefield file's size How can I get the filesize (eg, 2.12 MB) of a FileField upload?

I tried this from a views row template but I get an error message (function.filesize]: stat failed for ..filename..): 

// this correctly gets the result
// /sites/example.com/files/CIRS_manual_test.pdf
$file_field = '/' . $field-&gt;original_value;
print "&lt;a href='" . $file_field . '"&gt;Download chapter as pdf: ';
print filesize($file_field) . '&lt;/a&gt;';


I've tried using the full path /www/..., but get the same error message. I know the path is right because I'm able to load it in my browser.
Are you talking about getting the actual filesize or just formatting the size?

If the first, you can add a relationship to the {files} table in your view so that you can pull in the filesize column.  IIRC, you add a relationship to the fid and then you will see File: Size in the fields.  This will not work, though, if you manually overwrite the files via SFTP, etc.

You are getting the error because of the difference between the web path and the actual filesystem path.