webCOMAND

router::send_file()

Send data from a file to the browser.

Prototype

void send_file(string $path, array $options = [])

Parameters

  • path - Path to the file.  The file's contents will be sent to the browser.
  • options - Optional associative array of one or more of the following options.
    • filename - Filename for the data.  If not specified, the filename at the end of the path will be used.
    • disposition - Download disposition for the data ("inline" or "attachment").  If not specified, the Content-Disposition header will not be sent.
    • mimetype - Mime-Type to send as the Content-Type.  If not specified, it will be automatically determined from the data.
    • headers - Array of additional headers to send.  The array can be an associative array with the header as the key and value as the value, or a regular array (or numeric keys) where the value is the entire header to send.

Example

$router = new \io_comand_mvc\router(['exit'=>FALSE]);
if(!$router->route_request()) {
    $router->send_file('/path/to/image/error_file.html');
}