Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End cannot set header('Content-Length') greater than 2GB Reply To: cannot set header('Content-Length') greater than 2GB

#202681
ovi
Participant

you can try the following function instead of my_filesize():

function remote_filesize($url) {
    static $regex = '/^Content-Length: *+Kd++$/im';
    if (!$fp = @fopen($url, 'rb')) {
        return false;
    }
    if (
        isset($http_response_header) &&
        preg_match($regex, implode("n", $http_response_header), $matches)
    ) {
        return (int)$matches[0];
    }
    return strlen(stream_get_contents($fp));
}

Source: http://php.net/manual/en/function.filesize.php#114952