Download file instead of showing it

Discussion in 'HTML' started by Jens Müller, Jul 21, 2009.

  1. Jens Müller

    Jens Müller Guest

    Hello,

    is there a http-header to tell Firefox/IE to force to download a file (show
    "save as" dialog) instead of showing the contents (e.g. a .txt file)?

    How can this be done with Apache?

    Thanks!
     
    Jens Müller, Jul 21, 2009
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed Jens Müller <>
    writing in news:4a6600a3$0$32672$-online.net:

    > Hello,
    >
    > is there a http-header to tell Firefox/IE to force to download a file
    > (show "save as" dialog) instead of showing the contents (e.g. a .txt
    > file)?
    >
    > How can this be done with Apache?
    >
    > Thanks!
    >
    >


    You would have to change the content type. Probably the best thing to do
    all around is put the txt file into a zip file and offer that.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Jul 21, 2009
    #2
    1. Advertising

  3. Jens Müller wrote:
    > Hello,
    >
    > is there a http-header to tell Firefox/IE to force to download a file
    > (show "save as" dialog) instead of showing the contents (e.g. a .txt file)?
    >
    > How can this be done with Apache?
    >


    PHP

    $filename='somefile.txt';
    header('Content-Type: text/plain');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    echo $fileContents;


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Jul 21, 2009
    #3
  4. Jens Müller

    Newzie Guest

    On Tue, 21 Jul 2009 19:53:33 +0200, Jens Müller wrote:

    > Hello,
    >
    > is there a http-header to tell Firefox/IE to force to download a file (show
    > "save as" dialog) instead of showing the contents (e.g. a .txt file)?
    >
    > How can this be done with Apache?
    >
    > Thanks!


    Remove the mime type ;)
     
    Newzie, Jul 21, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Taylor
    Replies:
    2
    Views:
    1,026
    Ryan Taylor
    Nov 10, 2004
  2. Sam --
    Replies:
    2
    Views:
    669
    Sam --
    Mar 17, 2005
  3. Ray Booysen
    Replies:
    2
    Views:
    664
    Ray Booysen
    Mar 28, 2006
  4. Replies:
    3
    Views:
    510
    brucie
    Nov 9, 2005
  5. Brett  Kelly
    Replies:
    1
    Views:
    725
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
Loading...

Share This Page