0

我在我的网站上使用 onclick 按钮创建 10 个文件 xml,我想将所有 10 个文件放在 php 中的存档 .cab 扩展名中。

我尝试使用https://www.phpclasses.org/package/4056-PHP-Create-CAB-archives-from-lists-of-files.html中的 MakeCAB 类,但该类已过时。我尝试更新(我更改 __construct 的名称)它,但仍然出错并且输出 fil .cab 已损坏。我怎样才能做到这一点?请。

我仍然有 2 个错误 Undefined index 和 filettr 但我不知道如何定义它们,我不知道这是否是问题的原因,即 .cab 的生成工作但可能有大小限制重量或其他,因为它总是截断我一个文件。

function WriteFiles($res)
{ foreach ( $this->cabfiles as $file ) 
{ $this->WriteDword( $res, $file['ucomp'] ); 
$this->WriteDword( $res, $file['offset'] ); 
$this->WriteWord( $res, $file['index'] ); (line 314 ici) 
$this->WriteWord( $res, $file['date'] ); 
$this->WriteWord( $res, $file['time'] ); 
$this->WriteWord( $res, $file['fileattr'] ); (line 317 ici) 
$this->WriteByteBuffer( $res, $file['name'] ); 
} }

定义了一些变量和索引,但可能不是全部。

var $cabfile;
 /** * Array of files to be added to archive
 * * @var array * 
@access protected  */ 
var $cabfiles = array(); 

/** * Array of data for CAB folder
 * * @var array * 
@access protected*/ 
var $cabfolder = array(
'offset' => 44, ## offset of data            
'numblocks' => 0,  ## number of blocks           
'typecmp' => 1, ## 0 = no compression; 1 = MSZIP; LZX                                
'fileoffset' => 0  );

/** * Array of data for CAB Header * * 
@var array * 
@access protected */ 
var $cabheader = array(
'sig' => "MSCF",    ## signature             
'res1' => 0, ## reserved space          
'size' => 44, ## total size of cab file             
'res2' => 0,            
'offset' => 44,  ## offset of first data block      
'res3' => 0,            
'vmaj' => 1,    ## cab file format major version number 1            
'vmin' => 3,    ## cab file format minor version number 3            
'numfolders' => 1, ## must have at least one folder 

NewCABFolder()           
'numfiles' => 0, ## number of files in cab file              
'flags' => 0, ## not supported          
'setid' => 1234, ## set ID (not supported)           
'cabid' => 0, ##cab id not supported            
);
 /**

我像下面的代码一样调用类

//Send the MSCAB MIME type
 header("Content-Type:application/vnd.ms-cab- 
 compressed"); 

//Make it an attachment 
header('Content-Disposition: attachment; 
 filename="WinMSS.cab"'); 

//include the class file 
include'lib/makecab/MakeCAB.class.php'; 

//create object 
$cab = new MakeCAB("WinMSS.cab"); 

//add a local file system file 
$cab->addfile("WinMSS/STAGE.xml"); 
$cab->addfile("WinMSS/THEMATCH.xml"); 
$cab->addfile("WinMSS/CLASSIFY.xml"); 
$cab->addfile("WinMSS/CLUB.xml"); 
$cab->addfile("WinMSS/ENROLLED.xml"); 
$cab->addfile("WinMSS/MEMBER.xml"); 
$cab->addfile("WinMSS/SCORE.xml"); 
$cab->addfile("WinMSS/SQUAD.xml"); 
$cab->addfile("WinMSS/TAG.xml"); 
$cab->addfile("WinMSS/TEAM.xml");

//Make the file 
$cab->WriteCAB(); 

//output the file 
readfile("WinMSS.cab");

//delete the file 
unlink("WinMSS.cab"); } ?>

我对其他技术解决方案持开放态度:

使用在线压缩工具,但需要时间

使用与html css网站等兼容的php以外的语言...

请不要犹豫,给我一些想法,谢谢。

4

0 回答 0