Headers and "save as" dialog box.
From: Dariusz (ng_at_lycaus.plusYOUR***.com)
Date: 03/31/04
- Previous message: Tim: "Re: PHP control array syntax vs HTML standard"
- Next in thread: Ian.H: "Re: Headers and "save as" dialog box."
- Reply: Pedro Graca: "Re: Headers and "save as" dialog box."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Mar 2004 14:22:24 GMT
I have the following code which executes successfully to call the browsers
"save as" box...
//Screensavers
if ($FileType == 'scr')
{
// We'll be outputting a screensaver
header('Content-type: application/octet-stream');
// It will be called test.scr
header('Content-Disposition: attachment; filename="test.scr"');
// The location of the file
readfile('http://'.$FileURL);
}
The information for file locations etc is pulled from a database. What I
would like to do however is to be able to pull the filename from the
database and insert it as the filename, ie:
header('Content-Disposition: attachment; filename="$Name"');
But when I try to execute this, the "save as" box asks to save the file
$Name, and if I change the line to:
header('Content-Disposition: attachment; filename=$Name');
It then prompts to save the php code that is currently running.
Is there any way to insert the actual name of the file you are trying to
"save" rather than a generic name.
I've also tried writing:
echo "header('Content-Disposition: attachment; filename=\"$Name\"');";
But I get similar results.
Thanks for any help.
Dariusz
- Previous message: Tim: "Re: PHP control array syntax vs HTML standard"
- Next in thread: Ian.H: "Re: Headers and "save as" dialog box."
- Reply: Pedro Graca: "Re: Headers and "save as" dialog box."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]