note 6616 deleted from function.filesize by jimw

From: Date: Fri, 14 Dec 2001 20:14:40 +0000
Subject: note 6616 deleted from function.filesize by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22708@lists.php.net to get a copy of this message
About finding the file size of a remote file, I highly doubt that you could access this kind of information on a remote machine. This would be a huge security issue. If you really want to find the size of a file on a remote web server, you could write a socket script to connect to the desired HTTP server and by sending: HEAD /filefolder/file.jpg HTTP/1.1<CRLF> Host: www.yourhostname.com<CRLF><CRLF> Then the webserver should send you the header of that file which contains the header field "Content-Length: ". It's value is the size of the file requested. Note that you need the "Host: " header field if you specify HTTP version 1.1 (HTTP/1.1) or the server will respond with an error. Also, the command HEAD is not supported by all servers. You can use GET instead, but the server will send the header with the file content which will take longer to process. Check the HTTP RFC for more info on the protocol. If the file is not on a web server, then your on your own. ;) Seb

« previous php.notes (#22708) next »