function uncompress($srcName, $dstName) {
$sfp = gzopen($srcName, "rb");
$fp = fopen($dstName, "w");
while ($string = gzread($sfp, 4096)) {
fwrite($fp, $string, strlen($string));
}
gzclose($sfp);
fclose($fp);
}
我尝试了这段代码,但这不起作用,我得到:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求。请与服务器管理员联系,webmaster@domain.com 并告知他们错误发生的时间,以及您可能执行的任何可能导致错误的操作。有关此错误的详细信息,请参阅服务器错误日志。
此外,尝试使用错误文档处理请求时遇到 404 未找到错误。
试试这里找到的这个
//This input should be from somewhere else, hard-coded in this example
$file_name = '2013-07-16.dump.gz';
// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '', $file_name);
// Open our files (in binary mode)
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb');
// Keep repeating until the end of the input file
while (!gzeof($file)) {
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
fwrite($out_file, gzread($file, $buffer_size));
}
// Files are done, close files
fclose($out_file);
gzclose($file);