Im working on a site were users are to download particular files (.pdfs to be exact) after certain criteria is met. I've gotten everything to work, and even managed to link downloads to files not in the http structure.
Here is my pert. code:
$row = mysql_fetch_array($sql_result);
$link = $row["DOWNLOADLINK"];
$dlink = "/share/$link";
$fd = fopen("/share/$link","r+");
$book = fread($fd, filesize($dlink));
header("eBook");
echo $book;
Now, this works-to an extend. If I save the file on my harddrive instead of opening it in the browser, and then rename the file so that it has a .pdf extension, it works fine. (btw the file is always named fetchbook.htm during the download now; fetchbook.php is the script that gets the book). If I do nothing and simply open the file (from the webpage or simply not renaming the file) the browser thinks its a .htm file, and prints the files contents as if it were a page-which although is the file's contents, is just a bunch of garbage.
So, in short, how do get the echo $book; to output the correct file extension (or what have you) so that the file is correctly recognized as a .pdf and not an .htm?
Thanks!
-G