PHP Classes

Extract files simple code here

Recommend this page to a friend!

      Zip File  >  All threads  >  Extract files simple code here  >  (Un) Subscribe thread alerts  
Subject:Extract files simple code here
Summary:this is a simple code to get files from the .zip file
Messages:1
Author:Atef
Date:2011-05-19 20:32:06
 

  1. Extract files simple code here   Reply   Report abuse  
Picture of Atef Atef - 2011-05-19 20:32:06
<?php

require "zip.class.php"; // Get the zipfile class

$zipfile = new zipfile; // Create an object

$zipfile->read_zip("wordpress_zip.zip"); // Read the zip file



// Now, $zipfile->files is an array containing information about the files

// Here is an example of it's use and extracting files



foreach($zipfile->files as $filea)

{
//creating the directory if not exists
if(! file_exists($filea['dir']) && trim($filea['dir']) !='' & trim($filea['dir']) ){
mkdir($filea['dir'],0777,true);
}

if (trim($filea['dir']) != '.' && trim($filea['dir']) != '' ){
$dir=$filea['dir'].'/';
}else{
$dir=$filea['dir'];
}

if($filea['name'] != '.'){
file_put_contents( $dir.$filea['name'],$filea['data']);
}


}

?>