.txt
ファイル拡張子を維持したまま、PHPでファイルを圧縮したい。ファイルを解凍すると、.gz
ファイル内の拡張子 ( .txt
).gz
が削除されます。(test.txt
となります -> test
)
ファイルに圧縮test.txt
するPHP コードの例を次に示します。.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
ですか?