我想爲我創建的文件設置一個密碼。但是我現在使用的代碼不起作用。任何人都可以幫我嗎?如何使用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