On Friday 25 January 2002 02:23, Jason Wong wrote:
> In general, if the file is on disk then simply using:
>
> header("Location: http://www.domain.com/downloads/myfile.exe");
>
> would work. Whether the user is asked to "Save or Open..." depends on the
> browser setting.
>
> If you're using a webserver such as Apache then certain common file types
> are automatically recognised and the appropriate HTTP headers are sent to
> the browser.
>
>
> If you want to force a download regardless of whether the file type will be
> recognised by the browser then you would have to send your own headers.
> Something like the following:
>
> header("HTTP/1.0 200 OK");
> header("Content-Type: application/octet-stream");
> header("Content-Disposition: attachment; filename=some_filename");
> header("Content-Location: $F");
> header("content-length: " . filesize("/path/to/file.ext"));
> header("Location:http://www.domain.com/some_filename");
**CORRECTION** (I was trying to adapt some old code to use for this example)
header("HTTP/1.0 200 OK");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=some_filename");
header("Content-Location: some_filename");
header("content-length: " . filesize("/path/to/file.ext"));
readfile("/path/to/file.ext");
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Clear the laundromat!! This whirl-o-matic just had a nuclear meltdown!!
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]