src/Header.php
public static function send_file(
		string $fpath, $disposition=null, int $code=200, int $cache=0,
		array $headers=[], bool $xsendfile=null,
		callable $callback_notfound=null
	) {

		if (!file_exists($fpath) || is_dir($fpath)) {
			static::start_header(404, 0, $headers);
			if (is_callable($callback_notfound)) {
				$callback_notfound();
				static::halt();
			}
			return;
		}

		static::start_header($code, $cache, $headers);

		static::header('Content-Length: ' .
			filesize($fpath));
		static::header("Content-Type: " .
			Common::get_mimetype($fpath));

		if ($disposition) {
			if ($disposition === true)
				$disposition = htmlspecialchars(
					basename($fpath), ENT_QUOTES);
			static::header(sprintf(
				'Content-Disposition: attachment; filename="%s"',
				$disposition));
		}

		if (!$xsendfile)
			readfile($fpath);

		static::halt();
	}
public static function send_file(
		string $fpath, $disposition=null, int $code=200, int $cache=0,
		array $headers=[], bool $xsendfile=null,
		callable $callback_notfound=null
	) {

		if (!file_exists($fpath) || is_dir($fpath)) {
			static::start_header(404, 0, $headers);
			if (is_callable($callback_notfound)) {
				$callback_notfound();
				static::halt();
			}
			return;
		}

		static::start_header($code, $cache, $headers);

		static::header('Content-Length: ' .
			filesize($fpath));
		static::header("Content-Type: " .
			Common::get_mimetype($fpath));

		if ($disposition) {
			if ($disposition === true)
				$disposition = htmlspecialchars(
					basename($fpath), ENT_QUOTES);
			static::header(sprintf(
				'Content-Disposition: attachment; filename="%s"',
				$disposition));
		}

		if (!$xsendfile)
			readfile($fpath);

		static::halt();
	}
public static function send_file ( string $ fpath , $ disposition = null , int $ code = 200 , int $ cache = 0 , array $ headers = [ ] , bool $ xsendfile = null , callable $ callback_notfound = null ) { if ( ! file_exists ( $ fpath ) || is_dir ( $ fpath ) ) { static :: start_header ( 404 , 0 , $ headers ) ; if ( is_callable ( $ callback_notfound ) ) { $ callback_notfound ( ) ; static :: halt ( ) ; } return ; } static :: start_header ( $ code , $ cache , $ headers ) ; static :: header ( 'Content-Length: ' . filesize ( $ fpath ) ) ; static :: header ( "Content-Type: " . Common :: get_mimetype ( $ fpath ) ) ; if ( $ disposition ) { if ( $ disposition === true ) $ disposition = htmlspecialchars ( basename ( $ fpath ) , ENT_QUOTES ) ; static :: header ( sprintf ( 'Content-Disposition: attachment; filename="%s"' , $ disposition ) ) ; } if ( ! $ xsendfile ) readfile ( $ fpath ) ; static :: halt ( ) ; }
Send file.

Using higher-level Route::static_file_default is enough for
standard usage. Wrap this in Route::static_file_custom to make
a more elaborate static file serving instead of calling it
directly.

@param string $fpath Path to file.
@param mixed $disposition If set as string, this will be used
as filename on content disposition. If set to true, content
disposition is inferred from basename. Otherwise, no
content disposition header is sent.
@param int $code HTTP code. Typically it's 200, but this can
be anything since we can serve, e.g. 404 with a text file.
@param int $cache Cache age, 0 for no cache.
@param array $headers Additional headers.
@param bool $xsendfile If true, response is delegated to
web server. Appropriate header must be set via $headers,
e.g.: `X-Accel-Redirect` on Nginx or `X-Sendfile` on
Apache.
@param callable $callback_notfound What to do when the file
is not found. If no callback is provided, the method will
just immediately halt.
Send file .