- ⌂ controller
- Methods
controller::send_data()
Send file data to the browser.
Prototype
string 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 by calling mime_type::get_mime_type_from_file() internally.
Example
// the default controller method
public function web__index() {
$image = $this->repo()->get('FROM Image WHERE OID=123']);
$this->send_file($image->Data, ['filename'=>$image->Filename]);
}