Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Issue using pecl zip extension


    Anytime I try using the pecl zip extension I get an error specifically when trying to close the zip file. For instance in the following example it prints that it could not close the zip file. It seems I have done everything from installing pecl, the zip extension, putting the extension in the php.ini file and restarting httpd. I am really at a loss as to where to debug from here. I've included the zip test file that is not working properly.

    PHP Code:
    <?php

    $zip 
    = new ZipArchive();
    $filename "./test112.zip";

    if (
    $zip->open($filenameZIPARCHIVE::CREATE)!==TRUE) {
        exit(
    "cannot open <$filename>\n");
    }

    $zip->addFromString("testfilephp.txt" time(), "#1 This is a test string added as testfilephp.txt.\n");
    $zip->addFromString("testfilephp2.txt" time(), "#2 This is a test string added as testfilephp2.txt.\n");
    $zip->addFile($thisdir "/too.php","/testfromfile.php");
    echo 
    "numfiles: " $zip->numFiles "\n";
    echo 
    "status:" $zip->status "\n";
            if (
    $zip->close() === false) {
                    echo 
    "Could not close zip file $filename.";
                }
    ?>

  2. #2
    Can you please try this . I commented the line 12 .

    while executing the script in command prompt these are the results .

    numfiles: 2
    status:0

    and a ".zip" file called "test112.zip" . is created and these are the contents for the "test112.zip" .

    1. testfilephp.txt1338109653 (#1 This is a test string added as testfilephp.txt.)

    2. testfilephp2.txt1338109653 (#2 This is a test string added as testfilephp2.txt.)

    ================================================


    <?php

    $zip = new ZipArchive();
    $filename = "./test112.zip";

    if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    exit("cannot open <$filename>\n");
    }

    $zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
    $zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
    #$zip->addFile($thisdir . "/too.php","/testfromfile.php");
    echo "numfiles: " . $zip->numFiles . "\n";
    echo "status:" . $zip->status . "\n";
    if ($zip->close() === false) {
    echo "Could not close zip file $filename.";
    }
    ?>


    R








    Quote Originally Posted by saxophonemaster View Post
    Anytime I try using the pecl zip extension I get an error specifically when trying to close the zip file. For instance in the following example it prints that it could not close the zip file. It seems I have done everything from installing pecl, the zip extension, putting the extension in the php.ini file and restarting httpd. I am really at a loss as to where to debug from here. I've included the zip test file that is not working properly.

    PHP Code:
    <?php

    $zip 
    = new ZipArchive();
    $filename "./test112.zip";

    if (
    $zip->open($filenameZIPARCHIVE::CREATE)!==TRUE) {
        exit(
    "cannot open <$filename>\n");
    }

    $zip->addFromString("testfilephp.txt" time(), "#1 This is a test string added as testfilephp.txt.\n");
    $zip->addFromString("testfilephp2.txt" time(), "#2 This is a test string added as testfilephp2.txt.\n");
    $zip->addFile($thisdir "/too.php","/testfromfile.php");
    echo 
    "numfiles: " $zip->numFiles "\n";
    echo 
    "status:" $zip->status "\n";
            if (
    $zip->close() === false) {
                    echo 
    "Could not close zip file $filename.";
                }
    ?>

Posting Permissions

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