Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

How to extract zip files on ftp server using php script

We are not able to extract zip file in FTP. So we must need to connect control panel for extracting zip file.
If you want to extract your zip file on sever without opening your control panel you can you this simple php script.

class zlib_class {
     private $log_class = NULL;
     public function extractContents($source_file, $destination)
    {
           echo "in";
           $retval = false;
           $zip = new ZipArchive;
           if ($zip->open($source_file) === true)
          {
                 if ($zip->extractTo($destination))
                {
                     echo "if";
                     $retval = true;
                 }
                 else
                {
                        $error = array(
                        "error_class" => "zlib_class",
                        "error_code" => -2,
                        "error_description" => "Destination file could not be created."
                         );
                }
                $zip->close();
               }
               else
               {
                      $error = array(
                      "error_class" => "zlib_class",
                      "error_code" => -1,
                      "error_description" => "Source file could not be opened."
                      );
               }
               echo $retval;
               die();
               return $retval;
       }
}

$zip = new zlib_class();
if ($zip->extractContents("magento-1.7.0.2.zip","demo"))
{
         $output = array("task" => "Zip extraction completed.");
         //$log_class->logEvent($output);
}
else
{
         print("gotoskateorgohome.com Cron: Failure (2)");
}

Please support us, Like us on Facebook.

 

Copyright @ 2017 HKBlog.