Get remote file size using URL in PHP

php

Solution

You can use `curl_getinfo()` function to get the remote file size.

 $ch = curl_init('http://www.google.co.in/images/srpr/logo4w.png');

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_HEADER, TRUE);
 curl_setopt($ch, CURLOPT_NOBODY, TRUE);

 $data = curl_exec($ch);
 $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);

 curl_close($ch);
 echo $size;

Problem

I am trying to get image size using ``` get_headers($url) ``` But I am getting warning like ``` get_headers() [function.get-headers]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in ``` Is there any other way to Do so? Thanks.

Original source

Related problems