3

.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ですか?

4

1 に答える 1