Created
February 3, 2014 16:30
-
-
Save ehnydeel/8787146 to your computer and use it in GitHub Desktop.
PHP-Unzip
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 | |
// The unzip script | |
// This script lists all of the .zip files in a directory | |
// and allows you to select one to unzip. Unlike CPanel's file | |
// manager, it _will_ overwrite existing files. | |
// | |
// To use this script, FTP or paste this script into a file in the directory | |
// with the .zip you want to unzip. Then point your web browser at this | |
// script and choose which file to unzip. | |
// See if there's a file parameter in the URL string | |
$file = $_GET['file']; | |
if (isset($file)) | |
{ | |
echo "Unzipping " . $file . "<br>"; | |
system('unzip -o ' . $file); | |
exit; | |
} | |
// create a handler to read the directory contents | |
$handler = opendir("."); | |
echo "Please choose a file to unzip: " . "<br>"; | |
// A blank action field posts the form to itself | |
echo '<FORM action="" method="get">'; | |
$found = FALSE; // Used to see if there were any valid files | |
// keep going until all files in directory have been read | |
while ($file = readdir($handler)) | |
{ | |
if (preg_match ("/.zip$/i", $file)) | |
{ | |
echo '<input type="radio" name="file" value=' . $file . '> ' . $file . '<br>'; | |
$found = true; | |
} | |
} | |
closedir($handler); | |
if ($found == FALSE) | |
echo "No files ending in .zip found<br>"; | |
else | |
echo '<br>Warning: Existing files will be overwritten.<br><br><INPUT type="submit" value="Unzip!">'; | |
echo "</FORM>"; | |
?> |
On some server environments, the unzip command doesn't work at all; on others there might be limitations.
In general I do not have problems unzipping 500MB+ files.
I removed "-o" in line 17 and it start working
original system('unzip -o ' . $file);
changed system('unzip' . $file);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't unzip Wordpress.zip :-/
Zip-file is BIG.: 14MB
All I get is:
Unzipping WP-5.4.2-sv_SE.zip
Archive: WP-5.4.2-sv_SE.zip inflating: WP-5.4.2-sv_SE/index.php inflating: WP-5.4.2-sv_SE/license.txt inflating: WP-5.4.2-sv_SE/readme.html inflating: WP-5.4.2-sv_SE/wp-activate.php inflating: WP-5.4.2-sv_SE/wp-admin/about.php inflating: WP-5.4.2-sv_SE/wp-admin/admin-ajax.php inflating: WP-5.4.2-sv_SE/wp-admin/admin-footer.php ...
and nothing is unzipped :-/
PS. Small file is working!