Skip to content

Issue #21 Fix deprecation warning in PHP8 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
class File
{
const DEFAULT_CONTENT_TYPE = 'application/octet-stream';

/**
* @var bool whether to delete the tmp file when it's no longer referenced
* or when the request ends. Default is `true`.
Expand Down Expand Up @@ -66,16 +68,24 @@ public function __destruct()
*
* @param string|null $filename the filename to send. If empty, the file is
* streamed inline.
* @param string $contentType the Content-Type header
* @param string|null $contentType the Content-Type header to send. If
* `null` the type is auto-detected and if that fails
* 'application/octet-stream' is used.
* @param bool $inline whether to force inline display of the file, even if
* filename is present.
*/
public function send($filename = null, $contentType, $inline = false)
public function send($filename = null, $contentType = null, $inline = false)
{
if ($contentType === null) {
$contentType = @mime_content_type($this->_filename);
if ($contentType === false) {
$contentType = self::DEFAULT_CONTENT_TYPE;
}
}
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: '.$contentType);
header('Content-Type: ' . $contentType);
header('Content-Transfer-Encoding: binary');

//#11 Undefined index: HTTP_USER_AGENT
Expand Down