It sure does, Jamie, thanks! I tried the code you use, and that code will definitely prompt the file download dialog, but it won't allow a PDF file to open in Internet Explorer 6.1 for Win or Netscape 7.1 for Win.
I did, however, do some research to figure out how to do the abovementioned. In case anyone else is interested, I found some nifty CGI script at http://www.delorie.com/web/headers.html, which lets you view the headers of any web-based content.
I basically just copied the header information from a link that points directly to a PDF file (no PHP stuff) and included that information in my pdf_download.php file, and it works like a charm. The ticket was the E-Tag and Accept Ranges headers, which appear to be needed for the Acrobat Active-X control to read the file properly. Anyway, here's the code that works:
<?php
$dir="C:/my/protected/files/"; //this is the "offline" directory; Win32 users can use foreward slashes, too, not just UNIX/LINUX/ETC
if (isset($_REQUEST["file"])) { //checks to see if a file name was specified in the referring URL
$file = $dir . $_REQUEST["file"]; //if so, the $file variable is set to the name that was specified
if (file_exists("$file")) { //checks to see if the requested PDF file actually exists, and if it does, it gets passed through to download
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("ETag: \"eb73-96795-4d7a1300\"");
header("Accept-Ranges: bytes");
header("Content-Length: " . filesize($file));
header("Connection: close");
header("Content-Type: application/pdf");
readfile($file);
}
else {
//say whatever you want to say if the file name supplied was not valid for whatever reason
die();
}
}
?>
Hope someone finds this useful. Hell, use it with an authentication
script to serve up member-only documents or something.
Ben