Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit ca52142

Browse files
committed
Merge pull request #2 from badgio/master
Added sendDownload() bool param $forceDownload
2 parents 62e7a1a + adfb676 commit ca52142

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/FileDownload.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ public function __construct ($filePointer)
4848
* Sends the download to the browser
4949
*
5050
* @param string $filename
51+
* @param bool $forceDownload
5152
*
5253
* @throws \RuntimeException is thrown, if the headers are already sent
5354
*/
54-
public function sendDownload ($filename)
55+
public function sendDownload ($filename, $forceDownload = true)
5556
{
5657
if (headers_sent())
5758
{
@@ -63,7 +64,16 @@ public function sendDownload ($filename)
6364
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
6465
header("Cache-Control: private", false);
6566
header("Content-Type: {$this->getMimeType($filename)}");
66-
header("Content-Disposition: attachment; filename=\"{$filename}\";" );
67+
68+
if ($forceDownload)
69+
{
70+
header("Content-Disposition: attachment; filename=\"{$filename}\";" );
71+
}
72+
else
73+
{
74+
header("Content-Disposition: filename=\"{$filename}\";" );
75+
}
76+
6777
header("Content-Transfer-Encoding: binary");
6878
header("Content-Length: {$this->getFileSize()}");
6979

0 commit comments

Comments
 (0)