我想为我创建的文件设置一个密码。但是我现在使用的代码不起作用。任何人都可以帮我吗?如何使用zip命令行将密码设置为文件?
这是我当前的代码:
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));
}
,此有什么用gzip一部分? –
你没有提到任何有关代码中的'gzip'的内容。在'gzip'中没有直接的密码保护。从你的代码看起来像你使用'zip'。你的意思是“不工作”,你是否收到任何错误信息? – bansi
我知道我的代码没有gzip。我所显示的是当前使用的密码来保护我的文件的代码。但我正在寻找一种方法来用密码保护我的文件。 – user3026876