A while back I told you about a neat way to unzip files on the server.  Today I learned of a method that does the same thing, however this new method will overwrite files on the server.  This is great if you need to revert to an old version of WordPress, as I had to do this morning.

Just create a file called “unzip.php” and paste the following code into that file:

    // The unzip script
    // Created by Alex at http://www.learncpp.com
    // 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);
    // 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;
    if ($found == FALSE)
        echo "No files ending in .zip found<br>";
        echo '<br>Warning: Existing files will be overwritten.<br><br><INPUT type="submit" value="Unzip!">';
    echo "</FORM>";

Then upload unzip.php to the same directory as the file you want to unzip.

Then navigate to http://yourdomain.com/unzip.php and select the file you want to unzip.

Pretty neat, eh?

Many thanks to Learn CPP.


We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.




Enroll in Our Free Beginner WordPress Class - delivered to your Email Inbox!

Become a WordPress superstar for FREE in only minutes a day!  Our free Beginner WordPress Email Class will be delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!