簡體   English   中英

如何使用php操作zip文件中的文件

[英]How use php manipulate files inside zip files

我對zip文件中的文件有疑問,如果我在zip文件中有一些文本文件,是否有可能操縱該文本文件並更改該zip文件中的信息?

例如,如果我在test.zip內有文件test.txt,則可以打開此文本文件並更改內容並放入other,就像我使用fopen,fputs和fclose一樣,但都在zip內

我對此進行搜索,但一無所獲

最好的問候,謝謝

是的你可以! :)

像這樣:

$zip = new ZipArchive();
$zip->open('test.zip');

// Read from file
$contents = $zip->getFromName('test.txt');
var_dump($contents);

// Write to file
$zip->addFromString('test.txt', 'foo bar');

// Close (and re-pack) zip file. Don't miss that!
$zip->close();

檢查ZipArchive類的文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM