webCOMAND

router::send_data()

Send file data to the browser.

Prototype

void send_data(string $data, array $options = [])

Parameters

  • data - String of data to send to the browser.
  • options - Optional associative array of one or more of the following options.
    • filename - Filename for the data.
    • disposition - Download disposition for the data.
    • mimetype - Mime-Type to send as the Content-Type.  If not specified, it will be automatically determined from the data.

Example

$router = new \io_comand_mvc\router(['exit'=>FALSE]);
if(!$router->route_request()) {
    $image = get_file_contents('/path/to/image/error_file.png');
    $router->send_data($image, ['disposition'=>'attachment', 'filename'=>'error.png']);
}