On my web I want to have two buttons - first Download
that should download a pdf to the user\'s computer and another View
that opens pdf in a new t
In the end, as I use nginx, I decided to solve this at http-server level:
location /media {
alias /srv/www/novacek/media/;
}
location /download/media {
alias /srv/www/novacek/media/;
add_header Content-Disposition "attachment";
}
You need to force file download in your server-side script:
Here is a PHP example:
$file = "path/to/my-file.pdf";
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");