note 53098 deleted from function.filesize by aidan

From: Date: Wed, 13 Jul 2005 03:17:27 +0000
Subject: note 53098 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-91857@lists.php.net to get a copy of this message
Note Submitter: brausepaule at gmx dot de ---- Here is my remote filesize function, to get the filesize of a remote file without download the complete File. $uri ist the complete pfad to remote file! Greats Brause function remote_filesize($uri){ $url_p = parse_url ($uri); $host = $url_p['host']; if(isset ($url_p['port'])) $remote_port = $url_p['port']; else $remote_port = 80; $fp = @fsockopen ($host, $remote_port); if(!$fp) return 0; else { fputs($fp, 'HEAD '.$uri." HTTP/1.1\r\n"); fputs($fp, 'HOST: '.$host."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); $headers = ''; while (!feof ($fp)) $headers .= fgets ($fp, 128); } fclose ($fp); if (preg_match('/Content-Length:\s([0-9].+?)\s/', $headers, $matches)) return $matches[1]; else return 0; }

« previous php.notes (#91857) next »