PHP Code:
// Create a curl connection
$chGetSize = curl_init();
// Set the url we're requesting
curl_setopt($chGetSize, CURLOPT_URL, "http://www.example.com/file.exe");
// Set a valid user agent
curl_setopt($chGetSize, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11");
// Don't output any response directly to the browser
curl_setopt($chGetSize, CURLOPT_RETURNTRANSFER, true);
// Don't return the header (we'll use curl_getinfo();
curl_setopt($chGetSize, CURLOPT_HEADER, false);
// Don't download the body content
curl_setopt($chGetSize, CURLOPT_NOBODY, true);
// Run the curl functions to process the request
$chGetSizeStore = curl_exec($chGetSize);
$chGetSizeError = curl_error($chGetSize);
$chGetSizeInfo = curl_getinfo($chGetSize);
// Close the connection
curl_close($chGetSize);// Print the file size in bytes
echo $chGetSizeInfo['download_content_length'];
Comment