Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar

L10 Content-Length missing

$fullname = "pb_LSrdxU.zip";
return response()
    ->download($fullname, basename($fullname), [
            'Content-Length' => filesize($fullname)
    ])
    ->deleteFileAfterSend();
  HTTP/1.1 200 OK
  Date: Fri, 12 Apr 2024 16:45:35 GMT
  Server: Apache
  Cache-Control: no-cache, public
  Content-Disposition: attachment; filename=pb_LSrdxU.zip
  Accept-Ranges: bytes
  Last-Modified: Fri, 12 Apr 2024 16:45:35 GMT
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Transfer-Encoding: chunked
  Content-Type: application/zip

Using Apache, my Content-Length went missing despite not having done any changes. Any idea how to get it back?

0 likes
2 replies
Snapey's avatar

As a guess, filesize() needs the path to the file, not just its name.

laracoft's avatar

@Snapey it is a full path, just not shown in my snippet, i'm able to download the file, if i do a dd(filesize(...)); it dumps the correct value.

Please or to participate in this conversation.