使用php在gzopen中解压缩大型gzip文件时合适的缓冲区大小是多少? [英] What is suitable buffer size for uncompressing large gzip files in gzopen using php?

查看:143
本文介绍了使用php在gzopen中解压缩大型gzip文件时合适的缓冲区大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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);
}

我使用此代码进行解压缩,但无法正常工作,并且出现以下错误:

I use this code for uncompressing but It does not work and I get following error:


内部服务器错误

Internal Server Error

服务器遇到内部错误或配置错误,并且是
无法完成您的请求。

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

请与服务器管理员webmaster@example.com联系,
会告知他们发生错误的时间,而您可能所做的任何事情都可能导致错误。

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.

此外,尝试使用ErrorDocument处理请求时遇到了404 Not Found错误。

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


推荐答案

这应该有助于您查看错误消息。尽管目录必须可由php写入,但它将显示在屏幕上或打印到txt文件中。

This should help you see the error messages. Either it will displayed on the screen or will be printed into the txt file, although the directory must be writable by php.

<?php //top of script
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', 'errors.txt');

这篇关于使用php在gzopen中解压缩大型gzip文件时合适的缓冲区大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆