I've created a php file inside the root of my site (example.com/file.php):
$head = array_change_key_case(get_headers("https://example.com/somefile.zip", TRUE));
$filesize = $head['content-length'];
echo $filesize;
When I run the file, I get the following output: 1234173 It returns the file size in kilobytes. I also use the exact same code in my WordPress theme (example.com/wp-content/themes/my_theme/single.php), but there the output is always 0.
Why? (I use this code for getting size of files in my download box)
I get the same results, when using curl. (curl is ok in my root but it havent content-length parameter in wp)