Headers and "save as" dialog box.

From: Dariusz (ng_at_lycaus.plusYOUR***.com)
Date: 03/31/04

  • Next message: Florence HENRY: "Simultaneous sessions ?"
    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


  • Next message: Florence HENRY: "Simultaneous sessions ?"
  • Quantcast