I was thinking of doing a head request with cURL, was wondering if this is the way to go?
To get the file size, we will use filesize() function. The filesize() function returns the size of a file in bytes. This function accepts the filename as a parameter and returns the size of a file in bytes on success and False on failure.
The filesize() function returns the size of a file.
Using remote files ¶ ini , you can use HTTP and FTP URLs with most of the functions that take a filename as a parameter. In addition, URLs can be used with the include, include_once, require and require_once statements (allow_url_include must be enabled for these).
The best solution which follows the KISS principle
$head = array_change_key_case(get_headers("http://example.com/file.ext", 1));
$filesize = $head['content-length'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With