Results 1 to 5 of 5

Thread: php can't close the $zip

Threaded View

  1. #1
    Join Date
    Dec 2006
    Beans
    775

    php can't close the $zip

    Not clear what still needs doing.

    I have this small bundle of php (zipTest.php)...
    PHP Code:
    <?php
    $zip
    =new ZipArchive();
    $files=array('a.txt''b.txt''c.txt');
    $zipname='abc.zip';
    if (
    $zip->open($zipnameZipArchive::CREATE) !== TRUE) {die ('Could not open archive');}
    foreach (
    $files as $file) {$zip->addFile($file) or die ('Could not add file');}
    echo 
    'numFiles:'$zip->numFiles'<br>status:'$zip->status;
    $zip->close() or die ('<br>Could not close file');
    ?>
    ...in a virtually / locally hosted domain in my /home/directory....

    Both /home/directory (drwxrwxr-x 2 homeUser homeUser) and zipTest.php (-rw-rw-r-- 1 homeUser homeUser) seem to have the requisite reads and writes in place to allow the abc.zip file to be built and written to the /home/directory (by the homeUser).

    When I access zipTest.php via the browser (as homeUser), this is what appears...
    Code:
    numFiles:3
    status:0
    Could not close file
    ...showing (it seems) that the ZipArchive is created, three files (a, b and c) are added to it (numFiles:3) and that all is so far so good (status:0) - until zipTest.php fails to close (finish creating) abc.zip!

    Thanks for any suggestions.

    NB: I have also "777'ed" both the directory and php file, which I thought might address potential www-data / apache permissions issues - with the same results.
    Last edited by maclenin; May 15th, 2013 at 04:00 PM.

Bookmarks

Posting Permissions

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