note 110397 added to function.filesize

From: Date: Thu, 18 Oct 2012 10:42:37 +0000
Subject: note 110397 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-191416@lists.php.net to get a copy of this message
Getting the filesize of a remote file is not supported, since this function does not support STAT (hence the warning). However, when applying a HTTP address the request still got sent nonetheless, so the answer is already out there. We just have to inspect the response headers: <?php $iSize= @filesize( 'http://www.php.net/images/php.gif' ); if( $iSize=== FALSE && isset( $http_response_header ) && is_array( $http_response_header ) ) foreach( $http_response_header as $sHeader ) { if( preg_match( '#^Content-Length: ([0-9]+)$#i', $sHeader, $aMatch ) ) { $iSize= (int)$aMatch[1]; break; } } ?> ---- Server IP: 212.124.37.9 Probable Submitter: 85.180.159.210 ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- https://master.php.net/note/edit/110397 Del: integrated -- https://master.php.net/note/delete/110397/integrated Del: useless -- https://master.php.net/note/delete/110397/useless Del: bad code -- https://master.php.net/note/delete/110397/bad+code Del: spam -- https://master.php.net/note/delete/110397/spam Del: non-english -- https://master.php.net/note/delete/110397/non-english Del: in docs -- https://master.php.net/note/delete/110397/in+docs Del: other reasons-- https://master.php.net/note/delete/110397 Reject -- https://master.php.net/note/reject/110397 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191416) next »