如何在PHP中接收分块响应
我正在尝试接收已分块的.zip文件 这是我的密码:如何在PHP中接收分块响应,php,Php,我正在尝试接收已分块的.zip文件 这是我的密码: // cUrl function function send_request($url, $xml, $path, $save = TRUE){ if($save == TRUE){ $file = fopen($path, 'w'); // create a new file } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
// cUrl function
function send_request($url, $xml, $path, $save = TRUE){
if($save == TRUE){
$file = fopen($path, 'w'); // create a new file
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if($save == TRUE){
curl_setopt($ch, CURLOPT_FILE, $file); // save data direct to file
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
}
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
$response = curl_exec($ch);
curl_close($ch); // close curl conn
if($save == TRUE){
fclose($file); // close the file
}
return $response;
}
$zip = send_request($url, $xml_product, './xml_product_response.zip', TRUE);
这似乎是可行的,上面的代码创建了一个文件,其中包含许多奇怪的字符和标题
我现在被卡住了,因为我需要解压并读取文件中的数据
有人可以帮忙吗?来自:
CURLOPT_标题
:TRUE将标题包括在输出中。。为什么要启用它?我可以禁用它,我不是一个curl专业人士,它的curl脚本是我在php手册上找到的,禁用它并检查Nice one mate,效果很好