0
動態創建郵編嘗試在飛行中做出Zip文件,密碼PHP與密碼
<?php
$fileRequest = 'cooking-book';
// Prepare File
$file = tempnam("tmp", "zip");
$zip = new ZipArchive();
$zip->open($file, ZipArchive::OVERWRITE);
// Stuff with content
$getFile = file_get_contents('http://otherserver.com/getfile.php?sq='.$fileRequest);
$zip->addFromString('cooking-book.txt', $getFile);
// Close and send to users
$zip->close();
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$fileRequest.'.zip"');
readfile($file);
unlink($file);
?>
現在,它的做工精細(從其他服務器到存儲下載文件,壓縮它,並將其發送到用戶) 。
如何在zip上設置密碼? (exec()shell_exec()不能使用)在代碼中它必須是什麼?
謝謝。
添加它不幸的是我的PHP版本是不是5.6的,我不能upgrde它放在我的主機。其他方法? – 2014-10-01 09:08:22
這仍然不能在當前的PHP版本中運行,因爲setPassword僅用於解壓縮!請參見手冊中的說明: 此功能僅設置用於解壓檔案的密碼;它不會將非密碼保護的ZipArchive轉換爲受密碼保護的ZipArchive。 - http://docs.php.net/manual/en/ziparchive.setpassword.php – matt 2015-07-22 08:49:11