RE: [PHP] http headers - sending a file

From: Date: Fri, 28 Jul 2000 13:48:01 +0000
Subject: RE: [PHP] http headers - sending a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8779@lists.php.net to get a copy of this message
Hi Paul This works for me // Redirect the user to the file Header("Content-Type: application/octet-stream"); Header("Content-Disposition: filename=".$path['path']); readfile($DOCUMENT_ROOT."/files/".$path['path']); M@ > -----Original Message----- > From: Paul Dalton [mailto:paul@pinnacle.net.uk] > Sent: Friday, July 28, 2000 02:42 > To: php-general@lists.php.net > Subject: [PHP] http headers - sending a file > > > Hi, > A couple of days ago I asked how I might be able to password > protect files that people download. The best solution seemed to > be to get a script to fetch the file, hence hinding its location > from users. This is a good thing. We can do it in perl ok, but > the one problem is that when you open a file, and then print it > back to the client, the file you send ends up having the same > name as the script. So, someone (Jurian) suggested something like this: > > <? > $filename = "c:\\downloads\\file.exe"; > header("Content-Type: application/octet-stream"); > header("Content-Disposition: attachment; filename=$filename"); > ?> > > Unfortunately, this just generates a blank screen. I've had a > look at the RFC for http 1.1, but its a bit over my head. As far > as I can tell Content-Disposition: is experimental, or at least it was. > > So, any ideas people? I'd like to be able to send a file back to > the client, preserving the original filename. > > Thanks > > > Paul. >

« previous php.general (#8779) next »