note 110397 deleted from function.filesize by googleguy

From: Date: Thu, 18 Oct 2012 10:46:27 +0000
Subject: note 110397 deleted from function.filesize by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191419@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- 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; } } ?>

« previous php.notes (#191419) next »