You are viewing an old revision of this post, from May 20, 2015 @ 13:09:15. See below for differences between this version and the current revision.

Extract a zip file on a web server

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]<?php system("unzip example.zip") ?>[/php]

Untar

[php]<?php system("tar -zxvf example.tar.gz") ?>[/php]
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.

Revisions

  • May 20, 2015 @ 13:09:15 [Current Revision] by PeterLugg
  • May 20, 2015 @ 13:09:15 by PeterLugg

Revision Differences

There are no differences between the May 20, 2015 @ 13:09:15 revision and the current revision. (Maybe only post meta information was changed.)

Tags: ,

No comments yet.

Leave a Reply