web_response->sendFile

Sends a file or byte stream as a response.

Target member

Signature

1web_response->sendFile(data, name= null, ...)

Sends a file or byte stream as a response.

web_response->sendFile is called with member syntax on a receiver value. web_response->sendFile belongs at the request or response boundary. Treat visitor input as untrusted, validate before use, and encode values before writing them into HTML.

Parameters

data
Required value. Supply data positionally unless the signature shows a keyword form.
name
Optional value. Supply name positionally unless the signature shows a keyword form.
...
Additional values may be supplied after the earlier arguments.

Examples

Basic call

1web_response->sendFile(file('/tmp/report.pdf'), 'report.pdf')
The example belongs near a request or response boundary; validate visitor input before trusting it.