Results 1 to 5 of 5
  1. #1

    PHP and .gz ! Need Help!!


    I need help with .gz for a php script.

    I have uploaded a file.gz in my server. Its more than 18 mb in size and 25mb when unzipped.

    Its wud be really a pain if I go for uploading each and every file one by one without .gz.

    Now, I want a php script that will extract, for e.g, the file.txt.gz to file.txt in the same location of the server.

    Can anyone help me with the script pls.

    Fahad - a blog from a web addict

  2. #2
    Join Date
    Nov 2003
    See the comments here:

  3. #3
    Hello, I found this script from ur given url :

    function uncompress( $srcFileName, $dstFileName, $fileSize )
    // getting content of the compressed file
    $zp = gzopen( $srcFileName, "r" );
    $data = fread ( $zp, $fileSize );
    gzclose( $zp );

    // writing uncompressed file
    $fp = fopen( $dstFileName, "w" );
    fwrite( $fp, $data );
    fclose( $fp );

    And I used the function this way :
    uncompress("file.txt.gz", "file.txt", filesize("file.txt.gz"));

    But unfortunately, it just copied the original file to file.txt without uncompressing it.

    The uncompressed file should have been more than 24mb in size. but its still the same (16mb).

    Is there anyth wrong in the codes?
    Fahad - a blog from a web addict

  4. #4
    Join Date
    Nov 2003
    Try using gzread() instead of fread().

  5. #5
    I got it! Thanks man!

    Actually the variable filesize is the size of the file in extracted form.

    it worked fine!

    Fahad - a blog from a web addict

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts