LoginSignup
6
3

More than 3 years have passed since last update.

PHPでパスワード付きzipを作成

Last updated at Posted at 2019-05-16

作成方法

ネットを検索すると5系のexecなどを使わないとできないという情報のみだったのですが、PHP7.2以上は作成が可能です!

<?php

$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFromString('test.txt', 'file content goes here');
    $zip->setEncryptionName('test.txt', ZipArchive::EM_AES_256, 'password');
    $zip->close();
}

ぜひ、お試しください!

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3