Created
July 9, 2026 19:10
-
-
Save antoniocosentino/3bad1f508ad5b2f3dbd1df04d6b62f7c to your computer and use it in GitHub Desktop.
Unzip with PHP
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 | |
| $zipFile = __DIR__ . '/backup.zip'; | |
| $extractTo = __DIR__; | |
| echo "<pre>"; | |
| if (!file_exists($zipFile)) { | |
| die("Error: backup.zip not found in " . __DIR__); | |
| } | |
| $zip = new ZipArchive(); | |
| $result = $zip->open($zipFile); | |
| if ($result !== true) { | |
| die("Error: Could not open backup.zip (code: $result)"); | |
| } | |
| echo "Extracting backup.zip...\n"; | |
| if ($zip->extractTo($extractTo)) { | |
| echo "Extraction completed successfully.\n"; | |
| } else { | |
| echo "Error: Extraction failed.\n"; | |
| } | |
| $zip->close(); | |
| echo "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment