http headers - sending a file

From: Date: Fri, 28 Jul 2000 13:42:14 +0000
Subject: http headers - sending a file
Groups: php.general 
Request: Send a blank email to php-general+get-8778@lists.php.net to get a copy of this message
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 (#8778) next »