gpt4 book ai didi

php - 使用 php 在 gzopen 中解压缩大型 gzip 文件的缓冲区大小是多少?

转载 作者:行者123 更新时间:2023-12-03 22:55:59 26 4
gpt4 key购买 nike

function uncompress($srcName, $dstName) {
$sfp = gzopen($srcName, "rb");
$dstName = str_replace('.gz', '', $dstName);
$fp = fopen($dstName, "w");

fseek($FileOpen, -4, SEEK_END);
$buf = fread($FileOpen, 4);
$GZFileSize = end(unpack("V", $buf));

while ($string = gzread($sfp, $GZFileSize)) {
fwrite($fp, $string, strlen($string));
}
gzclose($sfp);
fclose($fp);
}

我使用这段代码进行解压缩,但它不起作用,并且出现以下错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

最佳答案

这个函数看起来很粗略。看来您正在用户区重新实现 stream_copy_to_stream()。忘掉缓冲区,只使用原生的东西。

function uncompress($srcName, $dstName)
{
$src = gzopen($srcName, 'rb');
$dst = fopen($dstName, 'wb');

stream_copy_to_stream($src, $dst);

gzclose($src);
fclose($dst);
}

想想看,您甚至可以使用 copy()

function uncompress($srcName, $dstName)
{
copy('compress.zlib://' . $srcName, $dstName);
}

关于php - 使用 php 在 gzopen 中解压缩大型 gzip 文件的缓冲区大小是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11267311/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com