Remote file size without downloading file
In PHP, you can use the get_headers()
function to retrieve the headers of a remote file. One of the headers returned is Content-Length
, which specifies the size of the file in bytes. You can use this value to determine the size of the file without downloading it.
Here is an example:
<?php
// URL of the file
$url = "https://workupload.com/start/c2kh9NB";
// Use the get_headers() function to retrieve the headers of the file
$headers = get_headers($url, 1);
// Check if the "Content-Length" header is present in the response
if (isset($headers["Content-Length"])) {
// Store the value of the "Content-Length" header in the $filesize variable
$filesize = $headers["Content-Length"];
// Output the size of the file
echo "The file size is: " . $filesize . " bytes";
} else {
// If the "Content-Length" header is not present, output an error message
echo "Unable to retrieve the size of the file.";
}
?>
Note that this only works for files that return the Content-Length
header. Some servers may not return this header, in which case you cannot determine the file size without downloading it.