您好,我正在使用下面的代码下载以从服务器检索 .zip 文件,我确实得到了该文件,但是我试图将其解压缩到同一个 php 文件中的文件夹中,但是当我运行我的脚本时,它会下载该文件,那么这是我得到的输出:
这是我得到的输出:
File Opening Successful
Warning: ZipArchive::extractTo() [ziparchive.extractto]: Invalid or unitialized Zip object in /home/content/38/10376438/html/viptravelink/xml/xml3.php on line 48
Warning: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object in /home/content/38/10376438/html/viptravelink/xml/xml3.php on line 49
Uncompression Successful
这是我正在使用的脚本:
<?php
/*
* XML Sender/Client.
*/
$xmlRequest = '<?xml version="1.0" encoding="utf-8"?>
<Request> <Source><RequestorID Client="***" EMailAddress="xml@***.com" Password="***" /> <RequestorPreferences Language="en" Currency="USD"> <RequestMode>SYNCHRONOUS</RequestMode> </RequestorPreferences> </Source> <RequestDetails> <ItemInformationDownloadRequest ItemType="hotel">
<IncrementalDownloads>
</IncrementalDownloads>
</ItemInformationDownloadRequest> </RequestDetails></Request>';
// We send XML via CURL using POST with a http header of text/xml.
$url = 'https://interface.demo.gta-travel.com/rbsusapi/RequestListenerServlet';
$ch = curl_init();
$zipPath = '/home/content/38/10376438/html/viptravelink/xml/' .date('m-d-Y_h-i-s'). '.zip';
$out = fopen($zipPath, 'wb');
echo "File Opening Successful<br>";
if ($out == FALSE){
echo "Download Failed<br>";
exit;
}
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 to fix Unknown SSL Protocol error
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt( $ch, CURLOPT_POSTFIELDS,$xmlRequest );
curl_setopt($ch,CURLOPT_ENCODING , "gzip");
curl_setopt($ch,CURLOPT_AUTOREFERER , 1);
curl_setopt($ch,CURLOPT_MAXREDIRS , 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result=curl_exec($ch);
$httpCode = curl_getinfo($ch);
curl_close($ch);
fclose($out);
$zip = new ZipArchive;
if (!$zip) {
echo "Could not make ZipArchive object.<br>";
exit;
}
$zip->open('$zipPath');
$zip->extractTo('/home/content/38/10376438/html/viptravelink/xml/content/');
$zip->close();
echo "Uncompression Successful<br>";
?>
任何帮助将不胜感激!!
谢谢!