我正在尝试为我创建的文件设置密码。但我现在使用的代码不起作用。有人可以帮帮我吗?
这是我目前的代码:
public function download_package_end (){
$form = $this->getUserData();
$end = "
</download>";
file_put_contents('download.xml', $end, FILE_APPEND);
echo shell_exec(`zip -P pass test.zip download.xml`);
$files = array(
'download.xml',
'script_.xml',
);
$zip = new ZipArchive();
$zip_name = "test.package";
if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){
$error .= "* Sorry ZIP creation failed at this time";
}
foreach($files as $file){
$zip->addFile($file);
}
echo shell_exec(`zip -P pass test.zip $files`);
$zip->close();
$DAO = $this->getDAO('DAO');
return $this->status(0,true,'select.success',$DAO->query('download_package_end',$form));
}
答案 0 :(得分:1)
你正在将shell_exec
与反引号结合起来,这没有任何意义。使用其中一个 - 它们是等价的。之一:
echo shell_exec("zip -P pass test.zip download.xml")
或
echo `zip -P pass test.zip download.xml`