I have a script that allows subscribers to download a monthly PDF. The PDFs are stored in a non-public directory, so I use the following script to get the files to them:
PHP Code:
$fileName = mysql_result($resIs,0,"fileName");
$fp = fopen($path .$fileName, "r");
header("Content-type: application/pdf");
fpassthru($fp);
fclose($fp);
So based on the download link that has been generated, it looks up the issue number to allow the download of the correct file.
For most users, this works fine - their browsers automatically open the file in their PDF reader. However, it downloads a file called "download.php" (which is the php file the above code is in) rather than say, "issue65.pdf" which is the actual file. They can manually rename download.php to a file name with a .pdf extension and it works fine, but I would like to fix this so the script just downloads a properly named pdf file, and I don't have the wherewithall to do so.
Any suggestions? Thanks.
|