diff --git a/src/Config/Events.php b/src/Config/Events.php index 9675662..87fab00 100644 --- a/src/Config/Events.php +++ b/src/Config/Events.php @@ -33,8 +33,19 @@ 'disposition' => $attachment['disposition'], 'type' => $attachment['type'], 'multipart' => $attachment['multipart'], - 'bytes' => filesize($attachment['name'][0]), + 'bytes' => getRemoteFileSize($attachment['name'][0]) ?? filesize($attachment['name'][0]), ]); } } }); + +function getRemoteFileSize($url) +{ + $headers = get_headers($url, 1); + + if (isset($headers['Content-Length'])) { + return $headers['Content-Length']; + } + + return false; +}