我正在与客户合作从他们的网络服务中获取 gzip。我可以通过以下电话获得回复:
$response = $client->call('branchzipdata', $param);
$filename = "test.gzip";
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $response) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
现在,当我尝试编写该文件时,例如“test.gzip”,之后我无法打开它......很可能是因为我做错了可怕的事情。任何见解将不胜感激。
编辑:
出于某种原因,我将文件保存为“.gzip”而不是“.gz”......所以为了让它工作,我现在有:
$response = $client->call('call', $param);
$content = base64_decode($response);
$filename = "output_zip.gz";
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
fclose($handle);
echo system("gzip -d $filename");