Re: How can the Surfer download

From: Date: Thu, 24 Jan 2002 18:31:15 +0000
Subject: Re: How can the Surfer download
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-81930@lists.php.net to get a copy of this message
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!! */

« previous php.general (#81930) next »