Skip to content

Commit 5d6ae12

Browse files
committed
fix: handle PDF attachment as inline content disposition, closes #3338
1 parent 493634d commit 5d6ae12

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

phpmyfaq/attachment.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,20 @@
120120

121121
$response->headers->set('Content-Type', $attachment->getMimeType());
122122
$response->headers->set('Content-Length', $attachment->getFilesize());
123-
$response->headers->set(
124-
'Content-Disposition',
125-
'attachment; filename="' . rawurlencode($attachment->getFilename()) . '"'
126-
);
127-
$response->headers->set('Content-MD5', $attachment->getRealHash());
128123

124+
if ($attachment->getMimeType() === 'application/pdf') {
125+
$response->headers->set(
126+
'Content-Disposition',
127+
'inline; filename="' . rawurlencode($attachment->getFilename()) . '"'
128+
);
129+
} else {
130+
$response->headers->set(
131+
'Content-Disposition',
132+
'attachment; filename="' . rawurlencode($attachment->getFilename()) . '"'
133+
);
134+
}
135+
136+
$response->headers->set('Content-MD5', $attachment->getRealHash());
129137
$response->send();
130138
} else {
131139
$attachmentErrors[] = Translation::get('msgAttachmentInvalid');

0 commit comments

Comments
 (0)