addFromString(...)" Can."/> addFromString(...)" Can.">
search
HomeBackend DevelopmentPHP ProblemHow to use php ziparchive

How to use php ziparchive

Mar 12, 2021 am 09:05 AM
php

php ziparchive usage: first open the test.zip file; then add the image.txt file to test.zip; finally add the image.txt file to the zip file through "$zip->addFromString(...)" Just append content to the test.txt file.

How to use php ziparchive

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php experience using ZipArchive to compress files

$zip=new ZipArchive;
if($zip->open('test.zip',ZipArchive::CREATE)===TRUE){
$zip->addFile('image.txt');//假设在当前路径下加入的文件名是image.txt
$zip->close();
}

Function: Open the test.zip file by default, create a test.zip file if it does not exist, and then add the image.txt file to test.zip.

Note: If image.txt is not added to the created zip file, the created compressed package will not be visible.

$zip->addFromString('test.txt','file content goes here');

Function: Append content to the test.txt file in the zip file

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of How to use php ziparchive. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools