downloading gz compressed files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    #1

    downloading gz compressed files?

    i have a short php script that creates a gz compressed file, but...
    when i try to download it, internet explorer doesn't prompt me for a
    download location, and then save it at that download location...
    instead, it just opens it as it would any old text document... this
    is not what i want it to do... i want to be able to download it, not
    view it. any ideas on how to do this?

    here's the code:

    <?
    system("ls -l | gzip > test.gz");
    print "download <a href=test.gz>he re</a>";
    ?>
  • SeeSchloss

    #2
    Re: downloading gz compressed files?

    Après mure réflexion, "yawnmoth" a écrit :[color=blue]
    > i have a short php script that creates a gz compressed file,
    > but... when i try to download it, internet explorer doesn't
    > prompt me for a download location, and then save it at that
    > download location... instead, it just opens it as it would any
    > old text document... this is not what i want it to do... i want
    > to be able to download it, not view it. any ideas on how to do
    > this?
    >
    > here's the code:
    >
    > <?
    > system("ls -l | gzip > test.gz");
    > print "download <a href=test.gz>he re</a>";
    > ?>[/color]

    Well you can always right click on the link and 'save
    as...'...


    --
    SeeSchloß - http://www.seeschloss.net

    Comment

    • Timo Henke

      #3
      Re: downloading gz compressed files?

      > > <?[color=blue][color=green]
      > > system("ls -l | gzip > test.gz");
      > > print "download <a href=test.gz>he re</a>";
      > > ?>[/color][/color]

      Your Webserver seems to not send the correct mime-type of the downloaded
      file.

      Try sending the mime-type on your own using the header() and send the
      filedata manually instead of providing a download link.

      $fp = fopen("test.gz" ,"rb");
      $size = filesize("test. gz");
      $content = fread($fp,$size );
      fclose($fp);

      Header('Content-Type: application/x-zip');
      Header('Content-Length: '. $size);
      Header('Content-disposition: inline; filename=test.g z');
      print $content;
      }

      (not sure with the mime-type .. you better look it up!)

      timo

      Comment

      • yawnmoth

        #4
        Re: downloading gz compressed files?

        On Tue, 30 Sep 2003 19:01:15 +0200, "Timo Henke" <webmaster@fli7 e.de>
        wrote:
        [color=blue][color=green][color=darkred]
        >> > <?
        >> > system("ls -l | gzip > test.gz");
        >> > print "download <a href=test.gz>he re</a>";
        >> > ?>[/color][/color]
        >
        >Your Webserver seems to not send the correct mime-type of the downloaded
        >file.
        >
        >Try sending the mime-type on your own using the header() and send the
        >filedata manually instead of providing a download link.
        >
        >$fp = fopen("test.gz" ,"rb");
        >$size = filesize("test. gz");
        >$content = fread($fp,$size );
        >fclose($fp);
        >
        > Header('Content-Type: application/x-zip');
        > Header('Content-Length: '. $size);
        > Header('Content-disposition: inline; filename=test.g z');
        > print $content;
        > }
        >
        >(not sure with the mime-type .. you better look it up!)
        >
        >timo[/color]

        that header command looks pretty nifty - thanks! :D

        Comment

        Working...