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