I’m trying to figure out the size of a downloadable file on an external server

Asked

Viewed 87 times

2

I’m making

public function remote_size()
{
    $url = 'http://200.152.38.155/CNPJ/DADOS_ABERTOS_CNPJ_01.zip ';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLOPT_NOBODY, TRUE);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36');

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

    curl_close($ch);

    echo $size;
    echo $data;
}

But what I have to answer for is this -1HTTP/1.1 400 Bad Request Date: Tue, 16 Jul 2019 13:02:28 GMT Server: Apache/2.4.6 (Centos) Openssl/1.0.2k-Fips Connection: close Content-Type: text/html; charset=iso-8859-1 Someone has an idea of something that might help me?

1 answer

1


  • Solved my problem, I had no idea it was such a simple thing. Thank you!!

  • 1

    For nothing rsrs Thumbs up if possible. Abs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.