Skip to content

Commit 10ad20b

Browse files
committed
fix: add content headers for download
1 parent 47a8f58 commit 10ad20b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Response.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,14 @@ public function download(string $file, string $name = null, int $code = 200)
165165
trigger_error("$file not found. Confirm your file path.");
166166
}
167167

168-
if ($name === null) $name = basename($file);
169-
170168
$this->headers = array_merge($this->headers, [
169+
'Expires' => '0',
170+
'Pragma' => 'public',
171171
'Content-Length' => filesize($file),
172-
'Content-Disposition' => "attachment; filename=$name",
172+
'Cache-Control' => 'must-revalidate',
173+
'Content-Description' => 'File Transfer',
174+
'Content-Type' => 'application/octet-stream',
175+
'Content-Disposition' => 'attachment; filename="' . $name ?? basename($file) . '"',
173176
]);
174177

175178
$this->content = $file;

0 commit comments

Comments
 (0)