-
-
Save ingmarioalberto/284f333b73ee4918d9b980af53ab3d7f to your computer and use it in GitHub Desktop.
Easiest way to download & extract zip files from a remote server to yours.
This file contains 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 | |
/* | |
1) upload this file into the folder you'd like to extract the content of the downloaded .zip file. | |
2) run the script in you browser. i.e. http://localhost/downunzip.php | |
3) after the script was executed sucesfully, login thru ftp and remove this script | |
*/ | |
/* you can change this */ | |
$download_url = "https://www.pulque.ro/m/wp-content2.tar"; | |
$T=explode("/", $download_url); | |
$delete = "no"; | |
/* don't touch nothing after this line */ | |
$file = $T[sizeof($T)-1]; | |
$script = basename($_SERVER['PHP_SELF']); | |
// download the file | |
file_put_contents($file, fopen($download_url, 'r')); | |
// extract file content | |
$path = pathinfo(realpath($file), PATHINFO_DIRNAME); // get the absolute path to $file (leave it as it is) | |
$phar = new PharData($path); | |
$res = $phar->extractTo('./'); | |
if ($res === TRUE) { | |
echo "<strong>$file</strong> extracted to <strong>$path</strong><br>"; | |
if ($delete == "yes") { unlink($file); } else { echo "remember to delete <strong>$file</strong> & <strong>$script</strong>!"; } | |
} else { | |
echo "Couldn't open $file"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment