note 26515 added to function.filesize

From: Date: Sat, 02 Nov 2002 08:34:46 +0000
Subject: note 26515 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-38899@lists.php.net to get a copy of this message
To anyone who has received a 'No such file or directory' error when using 'filesize' or 'filemtime' and you have the appropriate file access permissions, 'fopen' works, and the subject file exists, instead of using: $fname = "/usr/host/path/file.ext"; $fp = @fopen("$fname","r"); if ($fp and file_exists($fname)) { $fsize = intval(filesize($fp) / 1024); } fclose($fp); try: $fname = "/usr/host/path/file.ext"; if (file_exists($fname)) { $farray = stat($fname); $fsize = intval($farray[7] / 1024); // [7] is the index for file size in bytes } I tore my hair out before finding this solution. Cheers. -- http://www.php.net/manual/en/function.filesize.php http://master.php.net/manage/user-notes.php?action=edit+26515 http://master.php.net/manage/user-notes.php?action=delete+26515 http://master.php.net/manage/user-notes.php?action=reject+26515

« previous php.notes (#38899) next »