Modifying a single text file in a ZIP file, in PHP

后端 未结 2 1719
忘了有多久
忘了有多久 2020-12-29 06:44

I have a ZIP file on my server. I want to create a PHP file, loadZIP.php that will accept a single parameter, and then modify a text file within the ZIP to reflect that par

2条回答
  •  时光说笑
    2020-12-29 07:02

    In PHP 8 you can use ZipArchive::replaceFile

    As demonstrated by this example from the docs:

    open('test.zip') === TRUE) {
        $zip->replaceFile('/path/to/index.txt', 1);
        $zip->close();
        echo 'ok';
    } else {
        echo 'failed';
    }
    ?>
    

提交回复
热议问题