Re: Getting the filesize of an image?
| From: | Matt McClanahan | Date: | Sat, 01 Dec 2001 21:20:02 +0000 |
| Subject: | Re: Getting the filesize of an image? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76324@lists.php.net to get a copy of this message | ||
On Sat, Dec 01, 2001 at 11:05:51PM +0200, faeton wrote:
> Hello Matt,
>
> Of course it does not, but as i've already said file() with strlen()
> can be used. :)
>
> MM> If you want the size of a remote file, you'll have to download it; HTTP
> MM> doesn't provide a way to query a remote file's size. FTP does, if you have
> MM> FTP access.
Not on binary files. For an image that's 4494 bytes, file/join/strlen gives
me 3512. And since file() on a remote file is downloading it anyway, you
might as well do it right:
$fp = fopen('http://example.com/image.jpg','r');
while (!feof($fp))
$image .= fread($fp,1024);
echo strlen($image);
Matt