Re: How can the Surfer download

From: Date: Thu, 24 Jan 2002 18:23:26 +0000
Subject: Re: How can the Surfer download
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-81929@lists.php.net to get a copy of this message
On Friday 25 January 2002 01:35, Todd Cary wrote: > Jason - > > I had looked it up in the manual, but I am not sure of what to put into > the area /* ... output pdf file ... */ > > Any help is appreciated.... > > Todd > > ++++ > > If you want the user to be prompted to save the data you are sending, > such as a generated PDF file, you can use the Content-Disposition header > to supply a recommended filename and force the browser to display the > save dialog. > > <? php header("Content-type: application/pdf"); > header("Content-Disposition: attachment; filename=downloaded.pdf"); > > /* ... output pdf file ... */ 1) What kind of file are you letting people download? 2) Is the file generated on-the-fly or is it already on disk? 3) What webserver are you using? 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"); hth -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* TRANSACTION CANCELLED - FARECARD RETURNED */

« previous php.general (#81929) next »