利用PclZip打包下载

<?php
        /**
          * 真实路径寻出(创建下载包)
          */
         $file_name=time().$PRODUCT_ID.$p_name.'.zip';
         
         $archive = new PclZip($file_name);
         
         $v_list = $archive->create($attach_dir,PCLZIP_OPT_REMOVE_ALL_PATH);
         
         $new_file_dir=$ROOT_PATH.'attachment/dabao/'.$file_name;
         
         if ($v_list == 0) {
             die("Error : 找不到文件!");
         }else{
             if(rename(dirname(__FILE__)."\".$file_name,$new_file_dir)){
                 $filesize = sprintf("%u", filesize($new_file_dir));
                 
                 if (ob_get_length() !== false)
                     @ob_end_clean();
                 header('Pragma: public');
                 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
                 header('Cache-Control: no-store, no-cache, must-revalidate');
                 header('Cache-Control: pre-check=0, post-check=0, max-age=0');
                 header('Content-Transfer-Encoding: binary');
                 header('Content-Encoding: none');
                 header('Content-type: application/zip');
                 header('Content-Disposition: attachment; filename="' . $file_name . '"');
                 header('Content-length: ' . $filesize);
                 readfile($new_file_dir);
                 
                 unlink($new_file_dir);
             }else{
                 echo '创建失败!';
             }
         }
?>


pclzip-2-8-2