Posted by Andrew Taylor on 02/23/07 11:02
On 2005-03-31 15:59:36 +0100, StevePBurgess@gmail.com said:
> I would like to make my downloads section unbrowsable (to users) but
> accessible to scripts.
>
> Can I deliver a file to a browser without linking to it's URL so that I
> can deliver files programmatically but prevent users from browsing or
> linking to them?
>
> I am using PHP on an apache server.
>
> Ta
This is what I use on a PDF library I have, all you'd need to do is add
some logic in for the content-type and you're good to go.
Andrew
$filename =
'/home/user/a_path_not_available_via_web/documents/documentname.pdf';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: application/pdf");
header("Content-Disposition: attachment;
filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile($filename);
exit();
[Back to original message]
|