Simple Hack to unzip files on hosting space without SSH – PHP script

In the previous article I shared a PHP script to download files and here I’m sharing a simple script to unzip the downloaded files on the hosting server without SSH access. This is very useful when you want to setup a website on a new host and the hosting provider do not allow unzipping of large files, exceeding their maximum size limit. I have come across many free hosting providers that do not give SSH access (obvious) but they don’t allow unzipping of large files at least 20 Mb, I have come across one paid hosting provider that neither give SSH nor the unzipping options at all. Without further stories here’s the code snippet, enjoy.

You need to place below code in a php file in the same folder where .zip file is. Save the changes and visit this new php webpage from a browser, wait for a few minutes and your files will be unzipped.

// provide fie name
$file = '';
// get the absolute path to filename
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
 if ($res === TRUE) {
  $zip->extractTo($path); // extract file to the path
  echo "zing! $file extracted";
 else {
   echo "owwNoooo! the $file can not be opened";

To download file with PHP, follow below article.

Simple Hack download file with PHP script