4
A
回答
3
PHP有an extension,可讓您與ZIP檔案工作列出所有文件。
請注意,要訪問一個文件,您不需要解壓縮整個存檔。 ZipArchive::extractTo方法允許您指定要提取的內容。
$zip = new ZipArchive;
$res = $zip->open('test.zip');
$zip->extractTo('my/extract/folder/', 'foo.txt');
1
據我所知,壓縮數據不能以這種方式訪問,你必須首先解壓。
如果你是舒服,雖然,你可以使用這個PHP擴展:http://www.php.net/manual/en/book.zip.php
2
您可以使用PHP zip擴展爲:
foreach(glob('*.zip') as $zipFile) {
$zip = new ZipArchive;
if ($zip->open($zipFile) === TRUE) {
// get the filename without extension.
$filename = pathinfo($zipFile,PATHINFO_FILENAME);
// extract.
$zip->extractTo($filename);
$zip->close();
echo "Extracted contents of $zipFile to $filename","\n";
} else {
echo "Failed to open $zipFile","\n";
}
}
+1
你爲什麼要提取整個檔案? – 2010-12-13 10:29:09
1
你是否採取了看P HP5's ZipArchive
functions?
// you could extract the txt-file only and read in the content afterwards
$value = 'myzipfile.zip';
$entry = $zip->getNameIndex('foo.txt');
copy('zip://'.dirname(__FILE__).'/zip_files/'.$value.'#'.$entry, 'txt_files/'.$value.'.txt');
}
$zip->close();
// now you can access the file and do with the content what everyou like
相關問題
- 1. 從ZIP文件讀取目錄
- 2. java:從目錄中獲取.zip文件
- 3. 通過從文本文件讀取文件名從目錄中移動文件
- 4. 從URL讀取Zip文件與PHP
- 5. 從一個目錄中讀取ZIP文件中的單個文件
- 6. 從目錄中讀取文件並從Java中過濾文件
- 7. PHP文件讀取純文本文件
- 8. PHP - 從文本文件末尾讀取
- 9. PHP從文本文件讀取行
- 10. 從目錄中逐一讀取文件
- 11. 從Scala目錄中讀取文件
- 12. 如何從目錄中讀取文件
- 13. 從目錄中讀取文件名
- 14. Javascript從當前目錄中讀取文本文件
- 15. 從文本文件中讀取目錄時會發生變化
- 16. 從Zip文件中讀取CSV
- 17. 從zip文件中讀取的C庫
- 18. php從文本文件中讀取併合並重復條目
- 19. Windows RT:從項目文件夾中讀取文本文件
- 20. PHP-zip文件中的子目錄內的文件的file_get_contents()
- 21. 如何從FTP提取zip文件後讀取文本文件路徑
- 22. C#從讀取文本文件中讀取二進制文件
- 23. 我想從目錄文件夾中讀取文件
- 24. Python:從目錄中讀取文件並連接該文件
- 25. 批處理文件從文件名和目錄中讀取
- 26. 從Zip文件中的文件讀取內容
- 27. 如何從「.zip」文件中讀取所有「.java」文件
- 28. Powershell - 從.zip壓縮文件中讀取文件失敗
- 29. 從Ruby中的zip文件讀取文件評論
- 30. Ant從一個zip文件中讀取一個屬性文件
你必須解壓縮它。但不是整個檔案。您只能解壓縮所需的文件。 – 2010-12-13 10:24:39