php ZipArchive setPassword is not work
迷茫
迷茫 2017-04-11 09:59:04
0
1
390
$zip = new ZipArchive();
$code = $zip->open('myzip.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($code === true)
    echo 'zip opened<br>';
else
    echo $code.'<br>';
$zip->addFile('somefile');

$code = $zip->setPassword('secret');

if ($code === true)
    echo 'password set<br>';
else
    var_dump($code);

$code = $zip->close();

on the filesystem, the myzip.zip is created with somefile inside and $code is true but the zip file is not password protected ...
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

membalas semua(1)
洪涛

setPassword不是把一个没有密码的ZIP文件设置有密码的. 而是设置一个密码用来解密的.

$zip = new ZipArchive();
$code = $zip->open('myzip.zip');
$zip->setPassword('123456');
$zip->extractTo('/path');
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!