Re: Headers and "save as" dialog box.

From: Pedro Graca (hexkid_at_hotpop.com)
Date: 03/31/04


Date: 31 Mar 2004 15:23:57 GMT

Dariusz wrote:
> ...
> 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"');

Read the strings reference
    http://www.php.net/manual/en/language.types.string.php

taking particular attention to what is and is not interpolated.

$name = 'Pedro';
$name2 = 'my name is ' . $name; // my name is Pedro
$name3 = 'my name is $name'; // my name is $name
$name4 = "my name is $name"; // my name is Pedro
$name5 = 'my name is "$name"'; // my name is "$name"
$name6 = "my name is '$name'"; // my name is 'Pedro'

> 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');

try

    header('Content-Disposition: attachment; filename="' . $Name . '"');

which will output something like
    Content-Disposition: attachment; filename="test.scr"

No garanties this will work as you want on all browsers though :)

-- 
USENET would be a better place if everybody read:       : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html      : is valid for :
http://www.netmeister.org/news/learn2quote2.html        : "text/plain" :
http://www.expita.com/nomime.html                       : to 10K bytes :


Relevant Pages

  • Headers and "save as" dialog box.
    ... // We'll be outputting a screensaver ... The information for file locations etc is pulled from a database. ... would like to do however is to be able to pull the filename from the ...
    (comp.lang.php)
  • Re: Headers and "save as" dialog box.
    ... > The information for file locations etc is pulled from a database. ... > would like to do however is to be able to pull the filename from the ... The ' ' quotes you have inside the headercall are constant quotes, ...
    (comp.lang.php)
  • Re: Divining the full pathname of a file, all logicals translated
    ... If the database contains filenames that were not parsed with no_conceal, ... then the online filename and the database filename need to be parsed with ... return the filename using the disk logical that the disk was mounted with. ... drive name needs to be retained also, unmasked from any logicals. ...
    (comp.os.vms)
  • Re: store files at my web host - how
    ... I'm doing something similar with product images, so I'll post a little of my ... Then I try to get the filename alone (maybe ... to a database. ... You can grab a bit of metadata as well from the PostedFile, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: tool for finding paths to files
    ... the path and filename of the file you selected in the dialog box. ... So in my PictureLoad sample, the call is behind the "Choose a Picture" ... this to include other file formats or ALL file formats. ... is a small Access database ...
    (microsoft.public.access.forms)