Help extract Gzip .gz files with PHP

Discussion in 'PHP' started by alexeynn, Aug 25, 2008.

  1. #1
    Hi can anyone show me a working example of how to use gzip to
    decompress a file.
    I have read the docs at PHP help and I did not find the desired function.


    Start at this example of code

    <?php
    $filename = $filename.'.gz';
    ..... some gUnzip functions to extract filename.gz ....

    Server: Apache, PHP Ver: 5.2.5



    Alex
     
    alexeynn, Aug 25, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
  3. alexeynn

    alexeynn Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    but its does not help...
     
    alexeynn, Aug 25, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Can you make a (linux) system call?

    echo system("gunzip2 $filename 2>&1");
    PHP:
    The file will now go from $filename.gz to just $filename.

    Jay
     
    jayshah, Aug 25, 2008 IP
  5. alexeynn

    alexeynn Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you Jay, but

    sh: gunzip2: command not found sh: gunzip2: command not found
    Code (markup):
     
    alexeynn, Aug 25, 2008 IP
  6. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Hi,

    Do you have root, i.e. can you install it? :)

    Jay
     
    jayshah, Aug 25, 2008 IP
  7. alexeynn

    alexeynn Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I have a shared hosting... sorry, i dont know about root..
    Tell me what i should install and how?

    Thank you
     
    alexeynn, Aug 25, 2008 IP
  8. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
  9. alexeynn

    alexeynn Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    passthru("unzip 111.txt.gz");
    PHP:
    and

    system('tar -xzf 111.txt.gz');
    PHP:
    does not work
     
    alexeynn, Aug 26, 2008 IP
  10. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #10
    How about:
    echo system("/bin/gunzip $filename 2>&1");
    PHP:
    or
    echo system("gunzip $filename 2>&1");
    PHP:
    Jay
     
    jayshah, Aug 26, 2008 IP
  11. lol749

    lol749 Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    you could try this

    http://www.hawkee.com/snippet/2809/
     
    lol749, Aug 26, 2008 IP