class FileResponse (View source)

Constants

ACCEL

SENDFILE

FALLBACK

Methods

__construct(string $source, string $filename = '')

Initialize the response with a file path and optional download name

static bool
available(int $mode)

Check if a specific delivery mode is supported by the server environment Note: In the built-in web server, all modes will return true, allowing you to use the simulator to deliver the file

send(int $modes, bool $overwrite = false)

Dispatch the file using the preferred available delivery method

Details

__construct(string $source, string $filename = '')

Initialize the response with a file path and optional download name

Parameters

string $source

Absolute file path.

string $filename

Optional. Set download name (defaults to basename of $source).

static bool available(int $mode)

Check if a specific delivery mode is supported by the server environment Note: In the built-in web server, all modes will return true, allowing you to use the simulator to deliver the file

Parameters

int $mode

One of the mode constants (ACCEL or SENDFILE)

Return Value

bool

send(int $modes, bool $overwrite = false)

Dispatch the file using the preferred available delivery method

Parameters

int $modes

Set file delivery modes using bitwise flags (ACCEL, SENDFILE, FALLBACK).

bool $overwrite

Optional. Overwrite all possible related headers.

Exceptions

Exception