Skip to content

Instantly share code, notes, and snippets.

@muthu32
Created July 5, 2018 13:04
Show Gist options
  • Save muthu32/5efa634c31d724da8f71640276a1d1fd to your computer and use it in GitHub Desktop.
Save muthu32/5efa634c31d724da8f71640276a1d1fd to your computer and use it in GitHub Desktop.
//Download remote file
function getUrlFile($url, $path)
{
$newfilename = $path;
$file = fopen($url, "rb");
if ($file) {
$newfile = fopen($newfilename, "wb");
if ($newfile)
while (!feof($file)) {
fwrite($newfile, fread($file, 1024 * 8), 1024 * 8);
}
}
if ($file) {
fclose($file);
}
if ($newfile) {
fclose($newfile);
}
}
$path = '/var/www/vhosts/test.com/httpdocs/shop/mpdf.zip';
$url = 'https://php-download.com/downloads/mpdf/mpdf/7.1.1.0/mpdf_mpdf_7.1.1.0_require.zip';
getUrlFile($url, $path);
//system('unzip myzip.zip');
$zip = new ZipArchive;
$res = $zip->open('mpdf2/mpdf.zip');
if ($res === TRUE) {
$zip->extractTo('/var/www/vhosts/test.com/httpdocs/shop/');
$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