Skip to content

Instantly share code, notes, and snippets.

@baamenabar
Created October 1, 2014 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baamenabar/d4edd5b7f538f3f3152a to your computer and use it in GitHub Desktop.
Save baamenabar/d4edd5b7f538f3f3152a to your computer and use it in GitHub Desktop.
Download and deflate a ZIP file from a remote address.
<?php
$url = 'http://g.m0.cl/sistema/ci_assaabloy.zip';
$path = 'importado.zip';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
$zip = new ZipArchive;
$res = $zip->open($path);
if ($res === TRUE) {
$zip->extractTo('./');
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment