- ⌂ controller
- Methods
controller::send_file()
Send data from a file to the browser. This method ultimately calls view::send_file() internally.
Prototype
string 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 - 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.
- 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
// 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]);
}