Created
October 1, 2014 19:29
-
-
Save baamenabar/d4edd5b7f538f3f3152a to your computer and use it in GitHub Desktop.
Download and deflate a ZIP file from a remote address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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