What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [?] PHP ZipArchive...

[?] PHP ZipArchive...
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. Huh?  [?] PHP ZipArchive...
I'm trying to use the PHP ZipArchive class, but I can't seem to get it to work.  It always has a status of 0, and the folder is never created.  The script is uploaded here.
PHP code:
    print("<pre>Result of file system search:\n\n");
    print_r(glob("{level,scenario}s/*/*.mf{l,s}", GLOB_BRACE));
    print("\nOpening archive...\n");
    $zip = new ZipArchive();
    $zip -> open("files.zip", ZIPARCHIVE::CREATE) or die("Error: could not open archive.");
    print("\nLoading levels through iterator...\n");
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("levels/"));
    foreach ($iterator as $key => $value)
    {
        print("| ".$key." => ".$value."\n");
        $zip -> addFile(realpath($key), $key) or die ("Error: could not add file: ".$key);
    }
    print("\nLoading scenarios through iterator...\n");
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("scenarios/"));
    foreach ($iterator as $key => $value)
    {
        print("| ".$key." => ".$value."\n");
        $zip -> addFile(realpath($key), $key) or die ("Error: could not add file: ".$key);
    }
    print("\nTotal number of files: ".$zip -> numFiles."\nArchive status: ".$zip -> status."</pre>");
    $zip -> close();


This post was edited on 11-21-2010 at 03:26 PM by whiz.
11-21-2010 03:25 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] PHP ZipArchive...
Di you need to add the folder structure manually? I have never worked with ZipArchive before...
11-21-2010 03:41 PM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: [?] PHP ZipArchive...
I've tried using $zip->addEmptyDir() for the two directories and their subdirectories, but it doesn't make any difference.

This post was edited on 11-21-2010 at 04:12 PM by whiz.
11-21-2010 04:12 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On