Well, basically the trick is server-side, because of "content-disposition" directive in server response. No javascript in there.
If you have access to php or CGI scripts, you can add a wrapper that sends required header:
In apache you can create .htaccess file with content like this:
Code:
Action downloader /cgi-bin/wrapme.php
<Directory /path/to/files>
AddHandler downloader .pdf
</Directory>
while the wrapme.php (in this case, a php written wrapper) is:
PHP Code:
<?php
$file = $_SERVER['PATH_TRANSLATED'];
if (file_exists($file)) {
header('Content-type: application/pdf');
header('Content-transfer-encoding: binary');
header('Content-disposition: filename=' . basename($file));
header('Content-length: ' . filesize($file));
readfile("$file");
} else {
header("HTTP/1.0 404 Not found");
}
?>
Bookmarks