note 62259 deleted from function.filesize by nlopess

From: Date: Thu, 23 Feb 2006 18:26:54 +0000
Subject: note 62259 deleted from function.filesize by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104319@lists.php.net to get a copy of this message
Note Submitter: derick at php dot net ---- For HTTP and other streams based files, you can use a stream notifier to get the filesize. You don't have to resort to cURL or header parsing yourself.

<?php
 $ctxt = stream_context_create();
 stream_context_set_params($ctxt, array( "notification" => "notifier" ) );
 $f = fopen ($url, "rb", false, $ctxt );


 function notifier( $code, $severity, $msg, $xcode, $sofar, $fileSize )
 {
 if ( $code == STREAM_NOTIFY_FILE_SIZE_IS )
 {
 echo "SIZE = $fileSize\n";
 }
 }
?>

« previous php.notes (#104319) next »