[thelist] displaying file size in PHP

Paul Bennett Paul.Bennett at mch.govt.nz
Mon Oct 5 15:44:11 CDT 2009


Hi Joel,

filesize() will return false if the file doesn't exist (you can also use
file_exists() to check for (oddly enough) the existence of a file)

Also, you can't pass function references into a quoted string.

Try this instead:

$filesize = filesize($path/$file);
echo ($filesize)? $filesize.'Kb' : "File doesn't exist";


Paul


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Joel Canfield
Sent: Tuesday, 6 October 2009 9:37 a.m.
To: thelist at lists.evolt.org
Subject: [thelist] displaying file size in PHP

I've tried
$filesize = filesize($path/$file);
echo "$filesize<br />";

and

echo "filesize($path/$file)<br />";

and it just displays the words filesize(./path/to/the/file.asp)

where's the obvious bit I'm missing?

-- 
Joel at Bizba6.com
http://BizBa6.com/
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

www.mch.govt.nz  -  www.teara.govt.nz  -  www.nzhistory.net.nz  -  www.nzlive.com

The information contained in this email message does not necessarily reflect the views of the Ministry for Culture and Heritage and may contain information that is confidential or subject to legal privilege. If you are not the intended recipient and receive this email in error: please notify the Ministry for Culture and Heritage by return email or telephone (64 4 499 4229) and delete this email; you must not use, disclose, copy or distribute this message or the information in it.

PLEASE CONSIDER THE ENVIRONMENT BEFORE YOU PRINT THIS EMAIL






More information about the thelist mailing list