|
Posted by Iain Napier on 12/17/05 13:47
alex wrote:
>
> here is a bit of a script i use to open an a file and send it to the
> client.. you can use this to help.. (keep in mind, when we send
> headers, they must be the first thing sent, you can't have any output go
> to the client first) (also, using this method, i always use the ob
> buffer.. so all the headers and file stream are sent at the same time..
> works this way for me.. ymmv
>
> #------------------------------------
> ob_start();
> header('Content-type: application/x-gzip');
> header('Content-Disposition: attachment; filename="' . $file . '"');
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header("Cache-Control: post-check=0, pre-check=0", false);
> header("Pragma: no-cache");
> readfile($dir . $file);
> ob_end_flush();
> #------------------------------
>
> be sure to modify the content-type for whatever you're sending
That's worked brilliantly.
I've removed the world read attribute for all the files, and used your
chunk of code there to look at their absolute path on the web server.
No clients can view them directly via a browser, but they can read them
fine going via authentication then your script.
Just want I wanted! Many thanks :-)
[Back to original message]
|