Results 1 to 4 of 4

Thread: compress multiple files with Zlib [*RESOLVED*]

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    compress multiple files with Zlib [*RESOLVED*]

    Hey im am trying to compress multiple files using zlib but im not having any luck. I can compress single files but i cant find out how to create a table of contents for the .GZ file.

    I read that the files need to be read into an array than imploded by then " character then written to the file. It didnt work?

    Here is my code
    PHP Code:
    <?
    $files = array(
                    "test.jpg",
                    "test.png",
                    "test.php"
                    );
    foreach($files as $file){
        $temp = null;
        $fp_in = fopen($file,'rb');
        print "--opening "$file" for reading<br>";
        while(!feof($fp_in)){
            $temp .= fread($fp_in,1024);
        }
        $output[$file] = $temp;
        fclose($fp_in);
        print "--closing "$file"<br>";
    }

    $output = implode('"',$output);

    $fp = gzopen("output.gz","wb");
    print "opening "output.gz"<br>";
    gzputs($fp,$ouput);
    gzclose($fp);
    print "closing "output.gz"";
    ?>
    Last edited by john tindell; Aug 14th, 2004 at 08:42 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: compress multiple files with Zlib

    Originally posted by john tindell
    Hey im am trying to compress multiple files using zlib but im not having any luck. I can compress single files but i cant find out how to create a table of contents for the .GZ file.

    I read that the files need to be read into an array than imploded by then " character then written to the file. It didnt work?

    Here is my code
    PHP Code:
    <?
    $files = array(
                    "test.jpg",
                    "test.png",
                    "test.php"
                    );
    foreach($files as $file){
        $temp = null;
        $fp_in = fopen($file,'rb');
        print "--opening "$file" for reading<br>";
        while(!feof($fp_in)){
            $temp .= fread($fp_in,1024);
        }
        $output[$file] = $temp;
        fclose($fp_in);
        print "--closing "$file"<br>";
    }

    $output = implode('"',$output);

    $fp = gzopen("output.gz","wb");
    print "opening "output.gz"<br>";
    gzputs($fp,$ouput);
    gzclose($fp);
    print "closing "output.gz"";
    ?>
    Err -- It may be your spelling of $output on this line:
    PHP Code:
    gzputs($fp,$ouput); 
    This is why you should keep notices turned on while developing.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    cheers, always fdo have them on but it didnt show up for some reason?

    I think im going to scrap that idea and use ZIP files.

  4. #4

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

Posting Permissions

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



Click Here to Expand Forum to Full Width