使用 PHP 從 zip 存檔中讀取單個檔案的方法


若要讀取 zip 存檔中的單個檔案,程式碼如下所示 −

$handle = fopen('zip://test.zip#test.txt', 'r');
$result = '';
while (!feof($handle)) {
   $result .= fread($handle, 8192);
}
fclose($handle);
echo $result;

輸出將是 zip 檔案的內容。

更新日期: 2020 年 4 月 7 日

884 次瀏覽

開啟您的 職業

完成課程獲得認證

開始使用
廣告
© . All rights reserved.