download. Specifying a new response body

$response:download[DATA]   

This field is identical to
$response:body, but it sets flag that browser interprets as "Suggest that visitor save file to disk."

Browsers are able to display certain file types right within their windows (for example:
.doc, .pdf files).
Still, sometimes we should enable a visitor to download the file by simply clicking a relevant link.

Example: outputting a PDF file

A visitor is at page with such HTML:
<a href="/download_documentation.html">Download documentation</a>

download_documentation.html:
$response:download[^file::load[binary;documentation.pdf]]

…visitor clicks the link and browser suggests Open/Download.


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 20.09.2007