note 17850 added to function.filesize

From: Date: Fri, 28 Dec 2001 19:15:41 +0000
Subject: note 17850 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-23918@lists.php.net to get a copy of this message
If you want to get the filesize of a file only accessible by http you can do it like this (it took me a while to figure it out) ;) function httpfilesize($url) { $parts = preg_match('/http:\/\/([a-zA-Z0-9\.-]*)(\/.*)/', $url, $matches); $buffer = ''; $fp = fsockopen ($matches[1], 80, $errno, $errstr, 30); if (!$fp) return false; fputs ($fp, "HEAD ".$matches[2]." HTTP/1.1\r\nHost: ".$matches[1]."\r\n\r\n"); while (!feof($fp)) $buffer .= fgets ($fp,128); fclose ($fp); preg_match('/.*Content-Length: ([0-9]*).*/', $buffer, $ret); return $ret[1]; } -- http://www.php.net/manual/en/function.filesize.php http://master.php.net/manage/user-notes.php?action=edit+17850 http://master.php.net/manage/user-notes.php?action=delete+17850 http://master.php.net/manage/user-notes.php?action=reject+17850

« previous php.notes (#23918) next »