如何从远程网址获取真正的文件大小?

I have a shortcode to extract info from a file using a URL when this is requested by code says that file is 410 MB, but when this file is fully downloaded real file size is 390 MB, some way of getting file size 390 MB or a bit similar to end size?

<?php
$ch = curl_init($url);
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 round( $size / '1000000', 2);
?>

Your byte conversion is wrong. It 's a math issue and not a php issue.

Since a single kilobyte (KB) are 1024 bytes you have to convert single bytes with the factor 1048576, because 1048576 bytes are 1 megabyte.

Have a look at the accepted answer of this question.