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 - Content-Disposition for the data.  Options are:
      • inline (default) - indicates the file should display in the web browser if possible.
      • attachment - indicates the file should download.
    • 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']);
}