php如何压缩txt文件怎么打开,PHP-压缩txt文件,同时保持文件扩展名
我想在PHP中壓縮.txt文件,同時保持文件擴展名.當我解壓縮.gz文件時,.gz文件中的擴展名(.txt)被刪除. (test.txt變成-> test)
這是我的將test.txt壓縮為.gz文件的PHP代碼的示例:
// Name of the file we are compressing
$file = "test.txt";
// Name of the gz file we are creating
$gzfile = "test.gz";
// Open the gz file (w9 is the highest compression)
$fp = gzopen ($gzfile, 'w9');
// Compress the file
gzwrite ($fp, file_get_contents($file));
// Close the gz file and we are done
gzclose($fp);
?>
有人知道我在做什么錯嗎?還是因為gzip限制?
解決方法:
通常,在解壓縮時,gzip不會在gzip標頭中使用名稱,而且您也不會在標頭中存儲名稱.它只是從文件名中刪除.gz.您需要將文件命名為test.txt.gz才能將其解壓縮為test.txt.
標簽:compression,gzip,gz,php
來源: https://codeday.me/bug/20191030/1971302.html
總結
以上是生活随笔為你收集整理的php如何压缩txt文件怎么打开,PHP-压缩txt文件,同时保持文件扩展名的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: access-control-allow
- 下一篇: php调用dll函数,[转载]matla