Download multiple files as a zip-file using php

后端 未结 4 1496
醉梦人生
醉梦人生 2020-11-22 16:16

How can I download multiple files as a zip-file using php?

4条回答
  •  清酒与你
    2020-11-22 16:40

    You are ready to do with php zip lib, and can use zend zip lib too,

    open('app-0.09.zip') !== TRUE) {
        die ("Could not open archive");
    }
    
    // get number of files in archive
    $numFiles = $zip->numFiles;
    
    // iterate over file list
    // print details of each file
    for ($x=0; $x<$numFiles; $x++) {
        $file = $zip->statIndex($x);
        printf("%s (%d bytes)", $file['name'], $file['size']);
        print "
    ";    
    }
    
    // close archive
    $zip->close();
    ?>
    

    http://devzone.zend.com/985/dynamically-creating-compressed-zip-archives-with-php/

    and there is also php pear lib for this http://www.php.net/manual/en/class.ziparchive.php

提交回复
热议问题