Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract a .zip with php
    primarykey
    data
    text
    <p>Hello I am using the code below to download to retrieve a .zip file from a server, I do get the file however I am trying to unzip it into a folder within the same php file, but when I run my script it downloads the file, then this is the output I get:</p> <p>This is the output I get:</p> <pre><code>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 </code></pre> <p>This is the script I am using:</p> <pre><code> &lt;?php /* * XML Sender/Client. */ $xmlRequest = '&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Request&gt; &lt;Source&gt;&lt;RequestorID Client="***" EMailAddress="xml@***.com" Password="***" /&gt; &lt;RequestorPreferences Language="en" Currency="USD"&gt; &lt;RequestMode&gt;SYNCHRONOUS&lt;/RequestMode&gt; &lt;/RequestorPreferences&gt; &lt;/Source&gt; &lt;RequestDetails&gt; &lt;ItemInformationDownloadRequest ItemType="hotel"&gt; &lt;IncrementalDownloads&gt; &lt;/IncrementalDownloads&gt; &lt;/ItemInformationDownloadRequest&gt; &lt;/RequestDetails&gt;&lt;/Request&gt;'; // 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&lt;br&gt;"; if ($out == FALSE){ echo "Download Failed&lt;br&gt;"; 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.&lt;br&gt;"; exit; } $zip-&gt;open('$zipPath'); $zip-&gt;extractTo('/home/content/38/10376438/html/viptravelink/xml/content/'); $zip-&gt;close(); echo "Uncompression Successful&lt;br&gt;"; ?&gt; </code></pre> <p>Any help would be greatly appreciated!!</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload