note 28675 deleted from function.getimagesize by sniper
| From: | sniper@php.net | Date: | Mon, 14 Jul 2003 17:20:20 +0000 |
| Subject: | note 28675 deleted from function.getimagesize by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-52091@lists.php.net to get a copy of this message | ||
Note Submitter: mail@scherzbold.net
----
A simple function to get the filesize of a remote file.
function _fileSize($urlfile)
{
$url=parse_url($urlfile);
$host=$url['host'];
$path=$url['path'];
$fp = fsockopen($host, 80, &$errno, &$errstr, 20);
if(!$fp)
RETURN FALSE;
else
{
fputs($fp,"HEAD $urlfile HTTP/1.1\r\n");
fputs($fp,"HOST: dummy\r\n");
fputs($fp,"Connection: close\r\n\r\n");
$ourhead = "";
while(!feof($fp))
$ourhead = sprintf("%s%s", $ourhead, fgets ($fp,128));
}
fclose ($fp);
$split_head = explode("Content-Length: ",$ourhead);
$size = abs($split_head[1]);
RETURN $size;
}