ZipArchive() (adding a directory)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • techjohnny@gmail.com

    ZipArchive() (adding a directory)

    Hello, group:

    I'm able to successfully add files to a zip archive using php with the
    following script, but I can't find anywhere I add directories, can
    somebody help?


    Thanks,

    --TJ


    <?php

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

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

    $zip->addFromString( "testfilephp.tx t" . time(), "#1 This is a test
    string added as testfilephp.txt .\n");
    $zip->addFromString( "testfilephp2.t xt" . time(), "#2 This is a test
    string added as testfilephp2.tx t.\n");
    $zip->addFile($thisd ir . "/too.php","/testfromfile.ph p");
    $zip->close();
    ?>
  • wowo

    #2
    Re: ZipArchive() (adding a directory)

    On 29 Lut, 18:26, "techjoh...@gma il.com" <techjoh...@gma il.comwrote:
    Hello, group:
    >
    I'm able to successfully add files to a zip archive using php with the
    following script, but I can't find anywhere I add directories, can
    somebody help?
    >
    Thanks,
    >
    --TJ
    >
    <?php
    >
    $zip = new ZipArchive();
    $filename = "./test112.zip";
    >
    if ($zip->open($filename , ZIPARCHIVE::CRE ATE)!==TRUE) {
    exit("cannot open <$filename>\n") ;
    >
    }
    >
    $zip->addFromString( "testfilephp.tx t" . time(), "#1 This is a test
    string added as testfilephp.txt .\n");
    $zip->addFromString( "testfilephp2.t xt" . time(), "#2 This is a test
    string added as testfilephp2.tx t.\n");
    $zip->addFile($thisd ir . "/too.php","/testfromfile.ph p");
    $zip->close();
    ?>
    $zip->AddEmptyDirect ory($_folderNam e)
    if you wish to add file to this directory:
    $zip->AddFile($_fold erName .'/' . $_file);

    Comment

    Working...