Re: choosing the name to save a file as in a script
| From: | Kyle Jessup | Date: | Wed, 27 Dec 2000 01:29:08 +0000 |
| Subject: | Re: choosing the name to save a file as in a script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31900@lists.php.net to get a copy of this message | ||
> Hi everyone,
>
> I've seen something very interesting on some site that would allow me to
use
> PHP-authentification to allow download of certain files.... Here's what
the
> link on the site looks like:
>
> http://www.whatever.com/view.php3/filename.ext?id=17982
>
> Now, the script that sends the file is view.php3. What this does is get a
> file with id 17982, either by reading it from a database or something (not
> important) and sends it back to the browser and the browser thinks it is
> actually file "filename.ext"...
>
> What I don't get is how can you pass "/filename.ext?id=17982" as an
> argument? I tried it and the web server will of course look for file
> "filename.ext", but it doesn't exist since view.php3 is obviously not a
> directory...
With a slight bit more work, you can have this url:
view.php3?filename=<blah, blah, blah>
And I'M PRETTY SURE (I've done it before, but forget the details), you can
supply a HTTP header in your reply that indicates the filename like you want
it to.
It's Content-Disposition or something like that.
OK, to avoid sending you on a wild header chase, I tested it.
Adding "Content-Disposition: attachment=filename.ext" to the response header
did the trick. I was prompted to save the file with the proper name.
*sigh*, you might want to look at this though:
http://support.microsoft.com/support/kb/articles/Q267/9/91.ASP
- K