我想要一個zip文件(我不知道大小和名稱之前)與請求xml,返回一個zip文件。我想下載它,但有時會下載它(16mb左右)有時不會(2mb或4mb或1mb)我不知道爲什麼。下載zip PHP
這是我的代碼:
$ch2=curl_init();
curl_setopt($ch2, CURLOPT_URL, $this->URL);
curl_setopt($ch2, CURLOPT_TIMEOUT, 5040);
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS,$this->XMLRequest);
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch2, CURLOPT_SSLVERSION, 3);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true);
$xml = curl_exec($ch2);
curl_close($ch2);
$file2 = fopen('upload/item.zip','w+');
fwrite($file2, $xml);
fclose($file2);
我也曾嘗試:
file_put_contents('upload/item.zip', $xml);
有人能幫助我嗎?
我沒有看到curl_exec在你的代碼?它是$ xml = curl_exec($ ch2); – Dexa
編輯問題我錯過了一條線@Dexa –