note 81900 deleted from function.filesize by nlopess

From: Date: Tue, 18 Mar 2008 20:26:51 +0000
Subject: note 81900 deleted from function.filesize by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137182@lists.php.net to get a copy of this message
Note Submitter: bifor at free dot fr ---- If you need a function who can read the size of a link in the server and a external file ( from world wide web ) <?php function urlfilesize($url,$thereturn) { if (substr($url,0,4)=='http') { $x = array_change_key_case(get_headers($url, 1),CASE_LOWER); $x = $x['content-length']; } else { $x = @filesize($url); } if (!$thereturn) { return $x ; } elseif($thereturn == 'mb') { return round($x / (1024*1024),2) ; } elseif($thereturn == 'kb') { return round($x / (1024),2) ; } } $url = 'http://your-site/file.zip'; # example echo urlfilesize($url,'mb') ; # Will return the filesize of the link, in MegaByte. echo urlfilesize($url,'kb') ; # Will return the filesize of the link, in KiloByte. echo urlfilesize($url,'') ; # Will return the filesize of the link, in bytes ?> It's quite simple to use ;) Based on a function from http://www.tayo.fr/filesize-pour-une-url-aide.php

« previous php.notes (#137182) next »