Jeffrey van Rossum
Jeffrey van Rossum

Reputation: 173

Get ZIP file from generated URL

I have a URL that, when requested, start the download of a .zip file. The URL looks something like this: http://website.nl/servlets/ogexport?koppeling=WEBSITE&user=&password=&og=BOG&kantoor=**

How can I make sure that the zip file that gets generated in that proces get used in my PHP unzip script?

$file = 'testing.zip';
$path = pathinfo(realpath($file), PATHINFO_DIRNAME).'/xml';

// unzippen
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
    $zip->extractTo($path);
    $zip->close();
            echo 'success';
    // debug("ZIP bestand uitgepakt", 2);
} else {
    // debug("ZIP niet uitgepakt", 2);
    echo 'something went wrong.';
}

$xml_path = $path."/testing.xml";
echo $file.'<br>';
echo $xml_path;

Hoping for help!

Upvotes: 1

Views: 1114

Answers (1)

FabioCosta
FabioCosta

Reputation: 2749

I would recommend using php curl to download the remote file.Here is an example

Upvotes: 2

Related Questions