Views:

How to extract an uploaded ZIP or TAR file

Issue

Many applications come pre-packaged in a compressed ZIP or TAR file. Instead of unpacking these files on your local computer and then uploading the many files via FTP you can upload the compressed file and extract the files directly on the server to save you time. Unfortunately Plesk doesn't have a facility to do this from the control panel, but you can easily extract files using this following simple PHP script.

Solution

Create the following PHP file either directly from the Plesk File Manager or on your local computer and then upload it to the httpdocs directory. You could call it unzip.php or untar.php.

Select the appropriate method and then copy the line of code into the PHP file and then replace 'example.zip' or 'example.tar.gz' with the filename you wish to extract.

Unzip

<?php system("unzip example.zip") ?>

Untar

<?php system("tar -zxvf example.tar.gz") ?>

 

Upload the file you wish to extract and ensure your PHP file is in the same directory, usually in the httpdocs folder. Now run the command by visiting the untar.php URL in your browser. e.g. http://www.domain.co.nz/untar.php - Be aware that it may take a moment to extract the archive, so please ensure you only visit the URL once and allow it to complete. 

You will then want to delete the unzip.php or untar.php file from your hosting account, to avoid any accidental future extraction of your archives. If you've also finished with the original compressed file, delete this to save on your disk space.
 

Get in touch

For any additional help, give us a call on 0800 477 333 (8AM to 10PM, 7 days a week).