Skip to content

Instantly share code, notes, and snippets.

@mberizzo
Last active March 12, 2019 06:57
Show Gist options
  • Save mberizzo/9995be7fd591b9d60196b2f0bfc23010 to your computer and use it in GitHub Desktop.
Save mberizzo/9995be7fd591b9d60196b2f0bfc23010 to your computer and use it in GitHub Desktop.
PHP script that unzip file.zip
<?php
// When i have to upload multiple files in a shared hosting:
// 1. Compress your project and upload to your shared server
// 2. Visit url via shell (ex: "curl http://domain.com/unzip.php &") or any navigator
// Alternative step 2 (sometimes php throw timeout error):
// 1. Create a cronjob that visit unzip.php file (just one time)
error_reporting(E_ALL ^ E_STRICT);
ini_set('display_errors', 'On');
$file = 'file.zip';
// Get the absolute path to $file
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
// Extract it to the path we determined above
$zip->extractTo($path);
$zip->close();
echo "WOOT! $file extracted to $path";
} else {
echo "Doh! I couldn't open $file";
}
@Marcospucineri
Copy link

Las horas de subida de FTP que me has ahorrado con esta magia 💋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment